Remark Set SQL*Plus variables to manipulate output
set feedback off heading off verify off trimspool off
set pagesize 0 linesize 200
set sqlterminator '/'
Remark Set SQL*Plus user variables used in this script
define movetablespace = 'movetbs.sql'
define usrlist = '''SCOTT'',''ESYS'''
prompt *** Spooling to &movetablespace.
Remark 创建移动表空间的脚本
spool &movetablespace
SELECT 'ALTER TABLE ' || A.OWNER || '.' || A.TABLE_NAME ||
' MOVE TABLESPACE ' || B.DEFAULT_TABLESPACE || ';' AS CMD
FROM (SELECT OWNER, TABLE_NAME,TABLESPACE_NAME FROM ALL_TABLES WHERE OWNER IN (&usrlist.)) A,
(SELECT USERNAME, DEFAULT_TABLESPACE
FROM DBA_USERS
WHERE USERNAME IN (&usrlist.)) B
WHERE A.OWNER = B.USERNAME
AND A.TABLESPACE_NAME <> B.DEFAULT_TABLESPACE
/
spool off
set sqlterminator ';'
@&movetablespace.
host del &movetablespace.
exit
重建索引的表空间也类似
[@more@]来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/802415/viewspace-1035394/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/802415/viewspace-1035394/