select 'alter table smngdb. '||table_name||' move tablespace XMYJ' from dba_tables where wner='SMNGDB'
结果示例:
'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博客 ” ,链接:http://blog.itpub.net/196700/viewspace-680737/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/196700/viewspace-680737/