ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 迁移用户对象从一个表空间到另外表空间

迁移用户对象从一个表空间到另外表空间

原创 Linux操作系统 作者:shilei1 时间:2010-12-01 08:44:24 0 删除 编辑
例如:

select 'alter table smngdb. '||table_name||' move tablespace XMYJ' from dba_tables where wner='SMNGDB'

 

select 'alter table '||tname||' move  tablespace user1' from tab where rownum<=3;


结果示例:

'ALTERTABLESYS.'||TABLE_NAME||'MOVETABLESPACEEXAMPLE'
----------------------------------------------------------------------
alter table sys.MGMT_JOB_CRED_PARAMS move tablespace EXAMPLE
alter table sys.MGMT_JOB_SUBST_PARAMS move tablespace EXAMPLE
alter table sys.MGMT_JOB_PROP_PARAMS move tablespace EXAMPLE
alter table sys.MGMT_JOB_VALUE_PARAMS move tablespace EXAMPLE
alter table sys.MGMT_JOB_SEC_INFO move tablespace EXAMPLE
alter table sys.MGMT_JOB_LOCK_INFO move tablespace EXAMPLE
alter table sys.MGMT_JOB_LOCK_TARGETS move tablespace EXAMPLE
alter table sys.MGMT_JOB_SCHEDULE move tablespace EXAMPLE
alter table sys.MGMT_JOB move tablespace EXAMPLE
alter table sys.MGMT_JOB_TARGET move tablespace EXAMPLE
alter table sys.MGMT_JOB_FLAT_TARGETS move tablespace EXAMPLE

'ALTERTABLESYS.'||TABLE_NAME||'MOVETABLESPACEEXAMPLE'

 

要求from后面的数据字典中要有||连接符中间的字段。

 

PL/SQL中的一些符号:
:= 赋值操作符号
|| 连接操作符号
-- 单行注释符号
/* ... */ 多行注释符号
<<,>> 标签分隔符号
.. 范围操作符号
** 求幂操作符号

 

-----------------

首先移动表:
alter table table_name move tablespace tablespace_name;
然后,如果有索引的话必须重建索引:
alter index index_name rebuild tablespace tablespace_name

可以使用spool来帮助实现多个表的操作:
set header off;
spool /export/home/oracle/alter_tables.sql;
select 'alter table '||object_name||' move tablespace 表空间名'
from dba_objects
where wner='xxxx' and object_type='TBALE';
spool off;
之后执行此sql脚步即可
同样对于index也做同样的操作。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/196700/viewspace-680737/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 数据文件迁移
请登录后发表评论 登录
全部评论

注册时间:2018-10-10

  • 博文量
    548
  • 访问量
    130254