1、查找數據庫文件對應的File_ID:select * from dba_data_files
2、查詢當前表空間中的所有表:select distinct segment_name from dba_extents where segment_type='TABLE' and file_id='82'
3、查詢當前表空間中的所有索引:select distinct segment_name from dba_extents wheresegment_type='INDEX' and file_id='82'
4、如果有分區表,則查詢當前表空間中的所有的分區表:
select distinct segment_name from dba_extents where segment_type='TABLE PARTITION' and file_id=14
5、查詢當前表空間中的所有分區表的索引:
select distinct segment_name from dba_extents where segment_type='INDEX PARTITION' and file_id=14;
6、移動表到指定表空間(需要注意的是:Move命令不支持Long型字段 )
alter table Tbl_Name move tablespace New_TableSpaceName;
7、重建表的索引
alter index Index_Name rebuild tablespace New_TableSpaceName;
8、移動BLOB、CLOB的字段到指定表空間
alter table Tbl_Name move lob(BLOB1,BLOB2,BLOB3,......) store as (tablespace New_TableSpaceName);
9、移動BLOB、CLOB的字段語法
alter table table_name move [tablespace tbs_name] lob(lob_field1,lob_field2) store as (tablespace new_tbs_name);
10、如果LOB字段在分區表中,則增加partition關鍵字,如
alter table table_name move [partition partname] [tablespace tbs_name] lob(field) store as (tablespace new_tbs_name);
注:上面案例主要是開發人員在創建表的時候,表空間誤選系統表空間:USRES
可用select * from all_tables去查看