圖片中涉及的腳本在圖片下方。【腳本1】.select df.tablespace_name "表空間名",
totalspace "總空間M",
freespace "剩余空間M",
round((1 - freespace / totalspace) * 100, 2) "使用率%"
from (select tablespace_name, round(sum(bytes) / 1024 / 1024) totalspace
from dba_data_files
group by tablespace_name) df,
(select tablespace_name, round(sum(bytes) / 1024 / 1024) freespace
from dba_free_space
group by tablespace_name) fs
where df.tablespace_name = fs.tablespace_name
order by df.tablespace_name;
【腳本2】.create tablespace test_space datafile 'E:\APP\ADMINISTRATOR\ORADATA\DBSERVER\test_space.dbf'size 3G;
【腳本3】.--以下生成腳本(根據(jù)需要來調(diào)整需要生成的腳本)
SQL> set heading off
SQL> set echo off
SQL> set feedback off
SQL> set termout on
SQL> spool d:\move_test.sql
--要移動的表
select DISTINCT 'alter table '||||segment_name || ' move tablespace test_space;' from dba_extents where segment_type='TABLE' and file_id=37;
--要移動的索引
select DISTINCT 'alter index ' || owner||'.'||segment_name || ' rebuild tablespace test_space;'
from dba_extents
where segment_type = 'INDEX'
and file_id = 37;
--移動分區(qū)表
SQL>select DISTINCT 'alter table '|| segment_name || ' move partition '|| partition_name || ' tablespace test_space;' from dba_extents where segment_type='TABLE PARTITION' and file_id=18;
--移動分區(qū)索引
SQL>select DISTINCT 'alter index '|| segment_name || ' rebuild partition '|| partition_name || ' tablespace test_space;' from dba_extents where segment_type='INDEX PARTITION' and file_id=18;
SQL>spool off
--ps:然后執(zhí)行move_test.sql,注意保證test_space有足夠的空間容納這些數(shù)據(jù)。
【腳本4】.--以下生成腳本(根據(jù)需要來調(diào)整需要生成的腳本)
SQL> set heading off
SQL> set echo off
SQL> set feedback off
SQL> set termout on
SQL> spool d:\move_test2.sql
--表
select DISTINCT 'alter table '||segment_name || ' move tablespace TSP_ORDADM;' from dba_extents where segment_type='TABLE' and file_id=43;
--索引
select DISTINCT 'alter index ' || owner||'.'||segment_name || ' rebuild tablespace TSP_ORDADM;'
from dba_extents
where segment_type = 'INDEX'
and file_id = 43;
SQL>spool off
【腳本5】.--移到中轉(zhuǎn)表空間TEST_SPACE
ALTER TABLE LAB.LAB_IMAGE_RESULT MOVE TABLESPACE TEST_SPACE LOB(IMAGE) STORE AS(TABLESPACE TEST_SPACE);
--移回原表空間TSP_LAB
ALTER TABLE LAB.LAB_IMAGE_RESULT MOVE TABLESPACE TSP_LAB LOB(IMAGE) STORE AS(TABLESPACE TSP_LAB);
【腳本6】.--1.在sqlplus工具中可以help copy
--先創(chuàng)建對象
select dbms_metadata.get_ddl('TABLE','TEST1','TEST') from dual;
--2.可以通過dblink來插入
--本地以網(wǎng)絡(luò)登錄的形式test/oracle@king "king"連接字符串
--然后插入數(shù)據(jù)
COPY FROM test/oracle@king INSERT test.TEST1 (SERIES_NO,TABLE_CODE,TABLE_NAME,MANAGER_CLASS,REMARK)USING SELECT * FROM comm.FEE_TABLE_DICT@tsj--取數(shù)源 tsj 是dblink
3.TEST.TEST1表在所指定的表空間同步數(shù)據(jù)之后,
后續(xù)alter table...rename to...,然后drop源表空間上的老表(表空間resize之后,就做個逆向操作)。
dbtiger
good luck!
2018,3,30 于海南三亞
網(wǎng)頁題目:虛擬機(jī)搭建測試環(huán)境解決方案
網(wǎng)站鏈接:
http://weahome.cn/article/psshjp.html