Oracle Big Table

Source: Internet
Author: User
-- 1: Create Table partition tablespace tab_cc as select * From cc_event_reserve where rownum <1; -- close loggingalter table partition nologging; -- set session parallel dmlalter session enable parallel DML; -- 2: import data into the new table insert/* + append parallel (cc_event_reserve_new, 3) */into cc_event_reserve_new select/* + parallel (cc_event_reserve, 3) */t. * From cc_event_reserve t; commit; -- 3: obtain the maximum event_id value of the new table. The select max (event_id) from cc_event_reserve_new; -- 4: create index alter table partition add constraint partition primary key (event_id) using index tablespace idx_cc; -- create indexcreate index partition on cc_event_reserve_new (acct_book_id ASC) tablespace idx_cc parallel (degree 3) nologging; -- 5: Execute Table Analysis on the new table exec dbms_stats.gather_table_stats ('username', 'CC _ event_reserve_new ', Degree => 3, cascade => true, no_invalidate => false ); -- 6: Enable the logging function of the new table and delete the foreign key constraint alter table cc_event_reserve_new logging; alter table cc_event_reserve drop constraint logging; -- 7: Disable concurrent log enable for new table indexes alter index idx_cc_event_res_ AB _id_new noparallel; Alter index idx_cc_event_res_ AB _id_new logging; -- modify index ATTR. alter index into noparallel; Alter index into logging; -- 8: Rename, change the original table to cc_event_reserve_old to cc_event_reserverename cc_event_reserve to orders; -- rename tablerename failed to cc_event_reserve; -- 9: A small amount of data may exist in the original table. If a new table is not inserted, execute the following statement to insert it. Replace & event_id with the value found in Step 1: insert/* + append parallel (cc_event_reserve, 3) */into cc_event_reserve select/* + parallel (cc_event_reserve_old, 3) */t. * From cc_event_reserve_old t where T. event_id> & event_id and not exists (select 1 from cc_event_reserve_old T2 where t2.event _ id = T. event_id); Commit; -- 10: recreate the foreign key constraint alter table cc_event_reserve add constraint fk_cc_event_ref_acct_book foreign key (acct_book_id) References acct_book (acct_book_id ); alter table cc_event_reserve add constraint tables foreign key (event_format_id) References cc_event_format (event_format_id); -- 11: Delete the cc_event_reserve_old table drop table cc_event_reserve_old purge; -- 12: change the index name to the previous name alter index Rename to modify; Alter index Rename to pk_cc_event_reserve; -- 13 the constraint name is changed back to the previous name alter table cc_event_reserve rename constraint failed to pk_cc_event_reserve;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.