Online Move of a Table in Oracle Database 12c Release 2 (12.2)
In Oracle Database 12c Release 2 (12.2) you can now perform an online move of a table, as well as partitions and sub-partitions.
oracle 12cconfigurationintermediate
by OracleDba
11 views
In Oracle Database 12c Release 2 (12.2) you can now perform an online move of a table, as well as partitions and sub-partitions.
12345678910111213
DROP TABLE t1 PURGE;
-- Create table.
CREATE TABLE t1 AS
SELECT level AS id,
'Description for ' || level AS description,
SYSDATE AS created_date
FROM dual
CONNECT BY level <= 1000;
COMMIT;
ALTER TABLE t1 ADD CONSTRAINT t1_pk PRIMARY KEY (id);
CREATE INDEX t1_created_date_idx ON t1(created_date);123456789101112131415161718192021222324252627282930313233343536373839404142434445
-- Offline: Basic move.
ALTER TABLE t1 MOVE TABLESPACE users;
-- Check indexes.
SELECT index_name, status FROM user_indexes ORDER BY 1;
INDEX_NAME STATUS
------------------------------ --------
T1_CREATED_DATE_IDX UNUSABLE
T1_PK UNUSABLE
2 rows selected.
SQL>
-- Manually rebuild indexes.
ALTER INDEX t1_pk REBUILD ONLINE;
ALTER INDEX t1_created_date_idx REBUILD ONLINE;
-- Check indexes.
SELECT index_name, status FROM user_indexes ORDER BY 1;
INDEX_NAME STATUS
------------------------------ --------
T1_CREATED_DATE_IDX VALID
T1_PK VALID
2 rows selected.
SQL>
-- Offline: Include UPDATE INDEXES to manage the indexes.
ALTER TABLE t1 MOVE TABLESPACE users UPDATE INDEXES;
-- Check indexes.
SELECT index_name, status FROM user_indexes ORDER BY 1;
INDEX_NAME STATUS
------------------------------ --------
T1_CREATED_DATE_IDX VALID
T1_PK VALID
2 rows selected.
SQL>1234567891011121314151617181920212223
-- Online: Basic move.
ALTER TABLE t1 MOVE
ONLINE
TABLESPACE users;
-- Check indexes.
SELECT index_name, status FROM user_indexes ORDER BY 1;
INDEX_NAME STATUS
------------------------------ --------
T1_CREATED_DATE_IDX VALID
T1_PK VALID
2 rows selected.
SQL>
-- Online: Change table compression.
ALTER TABLE t1 MOVE ONLINE TABLESPACE users COMPRESS;
ALTER TABLE t1 MOVE ONLINE TABLESPACE users NOCOMPRESS;
-- Online: Change storage parameters.
ALTER TABLE t1 MOVE ONLINE STORAGE (PCTINCREASE 0);Please to add comments
No comments yet. Be the first to comment!