Sunday, June 29, 2014

Find and Move Tablespace Using by an Table.

Finding Tablespace used by tables....

SQL> SELECT TABLE_NAME, TABLESPACE_NAME
  2  FROM DBA_TABLES
  3  WHERE TABLE_NAME ='EMP'
  4  AND OWNER IN('RND');

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
EMP                            USERS


Moving Tablespace ......

SQL> ALTER TABLE RND.EMP
  2  MOVE TABLESPACE DATA;

Table altered.

Finding Tablespace used by tables....

SQL> SELECT TABLE_NAME, TABLESPACE_NAME
  2  FROM DBA_TABLES
  3  WHERE TABLE_NAME ='EMP'
  4  AND OWNER IN('RND');

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
EMP                            DATA


Writing scripts for all table move
[N.B:- Should be run so much carefully ]

SQL> SELECT  'ALTER TABLE '||TABLE_NAME||CHR(10)|| 'MOVE TABLESPACE '||TABLESPACE_NAME
  2  FROM DBA_TABLES
  3  WHERE OWNER IN(USER);

'ALTERTABLE'||TABLE_NAME||CHR(10)||'MOVETABLESPACE'||TABLESPACE_NAME
-----------------------------------------------------------------------------------------
ALTER TABLE FLASHBACK_DATABASE_TEST
MOVE TABLESPACE USERS

ALTER TABLE D
MOVE TABLESPACE USERS

ALTER TABLE PLSQL_PROFILER_RUNS
MOVE TABLESPACE USERS

ALTER TABLE PLSQL_PROFILER_UNITS
MOVE TABLESPACE USERS

No comments:

Post a Comment