简体   繁体   中英

How to copy all of partition from a table to another table

I have an oracle 11g production and test environment.Now i would like to copy all of the available partitions from production to test environment . is it possible to do it in a single go or i have to create the partition one by one using the alter table statement.

- Depending on your requirement you can use any of three partitions

  • Partition by range

      CREATE TABLE sales_range (salesman_id NUMBER(5), sales_date DATE) PARTITION BY RANGE(sales_date) ( PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02/01/2000','DD/MM/YYYY')), PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('03/01/2000','DD/MM/YYYY')), PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('05/01/2000','DD/MM/YYYY')) ); 
  • partition by list

      CREATE TABLE sales_list (salesman_id NUMBER(5), salesman_name VARCHAR2(30), sales_state VARCHAR2(20), PARTITION BY LIST(sales_state) ( PARTITION sales_west VALUES('California', 'Hawaii'), PARTITION sales_east VALUES ('New York', 'Virginia', 'Florida') ); 
  • partition by hash( if we not sure about how much data maps into a given range)

      CREATE TABLE sales_hash (salesman_id NUMBER(5), salesman_name VARCHAR2(30), ) PARTITION BY HASH(salesman_id) PARTITIONS 2 STORE IN (ts1, ts2); 
  • Subpartitions are also available

I Oracle 11 you can define partionized table in a way that partitions are automatically added when you insert/update any data. Then you don't have to care about it.

DDL is like this:

CREATE TABLE T_TABLE
(
  LOG_PROC_ID      NUMBER                       NOT NULL,
....
)
TABLESPACE MY_TABLESPACE 
PARTITION BY RANGE (LOG_PROC_ID) INTERVAL (10000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM