修改oracle表空间步聚

1.创建新的表空间

1.1针对于表

CREATE Tablespace  TS_OPRISK_DAT datafile '/oracle/oradata/cqbank/TS_OPRISK_DAT.dbf'

size 500m

autoextend on next  32m

maxsize 2048m extent

management local;

 

1.2针对于索引

CREATE Tablespace  TS_OPRISK_IDX datafile '/oracle/oradata/cqbank/TS_OPRISK_IDX.dbf'

size 500m

autoextend on next  32m

maxsize 2048m extent

management local;

 

2.执行以下sql打出的脚本

(针对修改普通表所属的表空间

即无BLOB和CLOB等字段类型的表

注:有BLOB或者CLOB类型的表会自动创建索引)

 

select 'alter table  '|| table_name ||' move tablespace TS_OPRISK_DAT;' from user_all_tables;

 

3.执行以下sql打出的脚本

(针对有BLOB或者CLOB类型的表)

 

select 'alter table '  || xtable || ' move tablespace TS_OPRISK_DAT lob' || '(' ||

column_name || ')  store as ( tablespace TS_OPRISK_DAT);'

from (select xtable,  wmsys.wm_concat(column_name) column_name

from (select owner ||  '.' || table_name xtable,

column_name,

tablespace_name

from dba_lobs

where owner='OPR' AND  tablespace_name = 'TSDAT01' AND TABLE_NAME NOT LIKE '%==$0')

group by xtable);

 

 

4.针对索引

select 'alter index  '|| index_name ||' rebuild tablespace TS_OPRISK_IDX;' from user_indexes a  WHERE INDEX_TYPE<>'LOB';

 

 

5.重建索引

select 'alter index  '|| index_name ||' rebuild; ' from user_indexes a WHERE  INDEX_TYPE<>'LOB';


你可能感兴趣的:(修改oracle表空间步聚)