How do you move a partitioned table from one tablespace to another in Oracle 11g?

后端 未结 6 826
清酒与你
清酒与你 2021-02-04 15:16

I have a partitioned table that belongs to tablespace report. I want to move it to tablespace record instead.

One possibility is to drop the table and

6条回答
  •  孤独总比滥情好
    2021-02-04 15:48

    The easiest way to move the data within tablespaces:

    Moving all non-partitioned tables

    SELECT 'ALTER TABLE '||OWNER|| '.'||TABLE_NAME||' MOVE TABLESPACE ARCHIVE;'  
    FROM ALL_tables 
    where owner = 'owner_name' 
    and temporary != 'Y'
    and partitioned != 'YES';
    

    Partitioned tables

    SELECT 'ALTER TABLE '|| TABLE_OWNER||'.'||TABLE_NAME||' MOVE PARTITION ' ||  PARTITION_NAME||  ' TABLESPACE ARCHIVE;'  FROM ALL_tab_partitions 
    WHERE TABLE_OWNER = 'owner_name' 
    AND table_NAME NOT LIKE 'BIN$%';
    

    Non-partitioned indexes

    SELECT 'ALTER INDEX '|| OWNER||'.'||OBJECT_NAME ||' REBUILD TABLESPACE ARCHIVE ;' 
    FROM ALL_OBJECTS 
    WHERE OBJECT_TYPE ='INDEX'
    AND OWNER = 'owner_name';
    

    Partitioned indexes

    SELECT  'ALTER INDEX '||I.INDEX_NAME||'REBUILD PARITION'|| S.PARTITION_NAME || ' TABLESPACE  ARCHIVE ' 
                       FROM  DBA_INDEXES I,    DBA_SEGMENTS S
                      WHERE  I.INDEX_NAME = S.SEGMENT_NAME
                        AND I.INDEX_TYPE IN ('NORMAL', 'BITMAP')
                        AND I.OWNER = 'owner_name'; 
    

提交回复
热议问题