如题,11G RAC环境,某次给表空间增容时命令运行了N遍,导致现在该表空间使用率只有10%。有没有什么办法(可能需要停DB?)将该表空间下的部分数据文件释放出来或者转到别的表空间名下?
第一、最简单,无风险,不影响应用,挨个resize 数据文件,保留表空间内数据文件数量不变
alter database datafile 'xxxxx' resize xxm;
或
第二迁移到其他表空间
1、新建一个表空间,
2、通过dba_segments查询误操作表空间有哪些对象,分别迁移到其他表空间,
--第1类:移动【表】所在表空间:
如将表table_name 移动到新的new_tbsp表空间
alter table table_name move tablespace new_tbsp;
--生成指定tbsp_name表空间下的【所有表】生成移动new_tbsp表空间SQL语句
select 'alter table '|| table_name|| ' move tablespace new_tbsp;' from user_tables where tablespace_name = 'tbsp_name'
--第2类:移动【索引】所在表空间:
如将索引index_name 移动到新的new_tbsp表空间(LOB数据类型的字段需按如下第3类处理)
alter index index_name rebuild tablespace new_tbsp;
--生成指定user_name用户下的【所有索引】生成移动new_tbsp表空间SQL语句
select 'alter index '||index_name||' rebuild tablespace new_tbsp;' from user_indexes where table_owner = 'user_name'
--第3类:移动【二进制流字段】数据存储表空间,如将表table_name中的二进制流字段col_name移动到new_tbsp表空间
alter table table_name move tablespace new_tbsp lob (col_name) store as (tablespace new_tbsp);
--生成指定表table_name中为CLOB类型的字段的移动到new_tbsp 表空间SQL语句
select 'alter table '|| table_name||' move tablespace new_tbsp lob ('|| column_name||' ) store as (tablespace new_tbsp);' from user_tab_columns
where data_type='CLOB' and table_name='table_name'
全部迁完,可以删除误建的表空间
评论
有用 1
墨值悬赏

