Thursday, 24 October 2019

Move TABLE sub partition

SET SERVEROUTPUT ON

BEGIN
FOR rec_subpart_tables IN (
SELECT DISTINCT TABLE_OWNER,TABLE_NAME,SUBPARTITION_NAME,TABLESPACE_NAME 
FROM ALL_TAB_SUBPARTITIONS
WHERE TABLE_NAME IN ('TABLE1','TABLE2')
)
LOOP
BEGIN
EXECUTE IMMEDIATE 'ALTER TABLE '||rec_subpart_tables.TABLE_OWNER||'.'||rec_subpart_tables.TABLE_NAME||' MOVE SUBPARTITION '||rec_subpart_tables.SUBPARTITION_NAME||' TABLESPACE DATA_TBS';
DBMS_OUTPUT.PUT_LINE('Successfully moved tablespace for sub partition table '||rec_subpart_tables.TABLE_OWNER||'.'||rec_subpart_tables.TABLE_NAME||' on partition '||rec_subpart_tables.SUBPARTITION_NAME);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Unable to move tablespace for subpartition table '||rec_subpart_tables.TABLE_OWNER||'.'||rec_subpart_tables.TABLE_NAME||' on partition '||rec_subpart_tables.SUBPARTITION_NAME||' with SQL Error '||SQLERRM);
END;
END LOOP;  
END;
/

No comments:

Post a Comment