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.
精彩评论