在Oracle 10g数据库中,我想重新创建一个表(保持其所有数据)作为索引组织。最简单的方法是什么?
答案 0 :(得分:3)
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.