Oralce - 用户表空间迁移

来源:互联网 发布:linux red hat使用教程 编辑:程序博客网 时间:2024/05/14 13:12

修改用户表空间

Alter user user_name default tablespace user_temp;                          --修改 user 默认表空间

Alter user user_name temporary tablespace user_temp;                          --修改 user 临时表空间

 

表空间修改后,用户之前的数据仍然在原来的表空间中存在,故不能删除原来的表空间,若要删除原来表空间,需要将

原来用户的表和索引等对象的表空间也进行迁移到新的表空间;


修改表的表空间

-- 单表转移表空间
alter table tab_name move tablespace new_space; commit;
 
-- 用户 QSS下的所有表都转移至表空间new_space下,但是表user被移动到表空间new_space后,表user上的索引是不会自动转移到表空间new_space
select 'alter table'||table_name||'move tablespace data_spa;commit;' from dba_tables where owner='QSS';


-- 单表下的索引转移表空间,例如,user表上的索引idx_user
alter index idx_user rebuild tablespace new_space

-- 用户 QSS下的所有索引都转移至表空间new_space下
select 'alter index'||index_name||'rebuild tablespace new_space;commit;' from dba_indexes where owner='QSS'
0 0
原创粉丝点击