Oracle 数据库修改索引表空间,包括修改表的表空间、修改索引的表空间、修改有CLOB字段的表空间等。
修改表空间语法
1、修改表的表空间
alter table TABLENAME move tablespace TABLESPACENAME;
2、修改索引的表空间
alter index INDEXNAME rebuild tablespace TABLESPACENAME;
3、修改有 CLOB 字段的表空间
alter table TABLENAME move tablespace TABLESPACENAME lob(COLUMNNAME) store as(tablespace TABLESPACENAME);
修改表空间示例
修改表
select 'alter table '||a.table_name||' move tablespace workflow;',
a.owner,a.table_name,a.tablespace_name,a.* from dba_tables a
where a.Owner='ERMIS_SHANXI'
order by a.owner,a.table_name;
修改索引
select 'alter index '||a.index_name||' rebuild tablespace workflow;',
a.owner,a.index_name,a.tablespace_name,a.* from dba_indexes a
where a.Owner='ERMIS_SHANXI'
order by a.owner,a.table_name;
修改 clob 索引
ALTER TABLE WF_H_PROCESSINSTATTR MOVE TABLESPACE WORKFLOW
LOB (ATTRIBUTE) STORE AS(TABLESPACE WORKFLOW);
如果遇见大字段,增加一个属性:
select 'alter index '||a.index_name||' rebuild tablespace VASD;',
a.owner,a.index_name,a.tablespace_name,a.* from dba_indexes a
where a.Owner='CMS200BJ2'
and index_type='NORMAL'
order by a.owner,a.table_name;
select 'alter index '||a.index_name||' rebuild tablespace VASD;',
a.owner,a.index_name,a.tablespace_name,a.* from dba_indexes a
where a.Owner='CMS200BJ2'
and index_type='LOB'
order by a.owner,a.table_name;
先查询所有涉及到大字段的表
SELECT DISTINCT a.table_name
FROM dba_indexes a
WHERE a.owner = 'CMS200BJ2' AND index_type = 'LOB'
转载自:http://www.linuxidc.com/Linux/2012-02/55268.htm