开发者

How can I recreate a table as index-organized?

开发者 https://www.devze.com 2023-02-25 11:58 出处:网络
In an Oracle 10g database I would like recreate a table (maintaining all of its data) as an index-organize开发者_运维问答d. What is the easiest way to do this?RENAME EXISTING_TABLE TO OLD_HEAP_TABLE;

In an Oracle 10g database I would like recreate a table (maintaining all of its data) as an index-organize开发者_运维问答d. What is the easiest way to do this?


RENAME EXISTING_TABLE TO OLD_HEAP_TABLE;

CREATE TABLE NEW_IOT_TABLE AS
 ([COLUMNS FROM EXISTING TABLE]
  CONSTRAINT NEW_IOT_TABLE_PK PRIMARY KEY ([PK_COLUMNS FROM EXISTING TABLE]
 )
 ORGANIZATION INDEX;


INSERT INTO NEW_IOT_TABLE
SELECT * FROM OLD_HEAP_TABLE;

COMMIT;

RENAME NEW_IOT_TABLE TO EXISTING_TABLE;

-- DROP OLD_HEAP_TABLE when you're sure it all worked.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号