实验环境:
11.1.0.6.0
 
对ANONYMOUSUSER_ALL表中分区进行备份
SQL> select TABLE_NAME,PARTITION_NAME,HIGH_VALUE,PARTITION_POSITION,TABLESPACE_NAME from user_tab_partitions where TABLE_NAME='ANONYMOUSUSER_ALL';

TABLE_NAME          PARTITION_NAM HIGH_VALUE                                     PARTITION_POSITION TABLESPACE_NAME
------------------------- ------------- -------------------------------------------------------------------------------- ------------------ ------------------------------
ANONYMOUSUSER_ALL      PART07_12    TO_DATE(' 2008-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA          1 PART
ANONYMOUSUSER_ALL      PART09_03    TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA          2 PART
ANONYMOUSUSER_ALL      SYS_P11720    TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA          3 P4
ANONYMOUSUSER_ALL      SYS_P11721    TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA          4 P5
ANONYMOUSUSER_ALL      SYS_P11722    TO_DATE(' 2011-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA          5 P3
ANONYMOUSUSER_ALL      SYS_P11724    TO_DATE(' 2011-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA          6 P5
ANONYMOUSUSER_ALL      SYS_P11725    TO_DATE(' 2011-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA          7 P3
ANONYMOUSUSER_ALL      SYS_P11728    TO_DATE(' 2012-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA          8 P3
ANONYMOUSUSER_ALL      SYS_P11729    TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA          9 P4
ANONYMOUSUSER_ALL      SYS_P11731    TO_DATE(' 2012-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA         10 P3
ANONYMOUSUSER_ALL      SYS_P11732    TO_DATE(' 2012-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA         11 P4
ANONYMOUSUSER_ALL      SYS_P11733    TO_DATE(' 2012-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA         12 P5
ANONYMOUSUSER_ALL      SYS_P11755    TO_DATE(' 2012-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA         13 P5

13 rows selected.

 
 
 
对SYS_P11720分区进行备份
SQL> select count(*) from ANONYMOUSUSER_ALL partition(SYS_P11720);

COUNT(*)
----------
     25240

 
SQL> select CTIME from ANONYMOUSUSER_ALL where rownum<2;

CTIME
------------
01-JUN-11

 
使用exp导出SYS_P11720分区
[oracle@hou-test backup]$ exp part/part file=ANONYMOUSUSER_ALL_201106.dmp tables=ANONYMOUSUSER_ALL:SYS_P11720

Export: Release 11.1.0.6.0 - Production on Mon Jul 23 06:56:49 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
EXP-00006: internal inconsistency error
EXP-00000: Export terminated unsuccessfully

 
出错,exp不支持11g分区表的新特性(ANONYMOUSUSER_ALL是11g的新特性interval分区),解决办法,采用数据泵expd
 
 
 
一、创建dump目录
create directory dump as '/home/oracle/backup';
grant read,write on directory dump to part;

二、备份
1.分区表全表备份

[oracle@hou-test backup]$ expdp part/part directory=dump dumpfile=ANONYMOUSUSER_ALL.dmp tables=ANONYMOUSUSER_ALL

Export: Release 11.1.0.6.0 - 64bit Production on Monday, 23 July, 2012 7:29:08

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "PART"."SYS_EXPORT_TABLE_01":  part/******** directory=dump dumpfile=ANONYMOUSUSER_ALL.dmp tables=ANONYMOUSUSER_ALL
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 91.06 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11725"     13.71 MB   88534 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11724"     13.02 MB   83637 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11728"     11.18 MB   70963 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11722"     7.103 MB   45357 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11731"     6.251 MB   39730 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11732"     5.743 MB   36423 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11729"     4.575 MB   29288 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11720"     3.903 MB   25240 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11733"     3.645 MB   23010 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11721"     2.788 MB   17762 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11755"     10.68 KB       1 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"PART07_12"          0 KB       0 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"PART09_03"          0 KB       0 rows
Master table "PART"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for PART.SYS_EXPORT_TABLE_01 is:
  /home/oracle/backup/ANONYMOUSUSER_ALL.dmp
Job "PART"."SYS_EXPORT_TABLE_01" successfully completed at 07:29:30

 
 
2备份一个分区
[oracle@hou-test backup]$ expdp part/part directory=dump dumpfile=ANONYMOUSUSER_ALL_201106.dmp tables=ANONYMOUSUSER_ALL:SYS_P11720

Export: Release 11.1.0.6.0 - 64bit Production on Monday, 23 July, 2012 7:34:15

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "PART"."SYS_EXPORT_TABLE_01":  part/******** directory=dump dumpfile=ANONYMOUSUSER_ALL_201106.dmp tables=ANONYMOUSUSER_ALL:SYS_P11720
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 5 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11720"     3.903 MB   25240 rows
Master table "PART"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for PART.SYS_EXPORT_TABLE_01 is:
  /home/oracle/backup/ANONYMOUSUSER_ALL_201106.dmp
Job "PART"."SYS_EXPORT_TABLE_01" successfully completed at 07:34:36

3.备份多个分区
SQL> select count(*) from ANONYMOUSUSER_ALL partition(SYS_P11721);

COUNT(*)
----------
     17762

SQL> select ctime from ANONYMOUSUSER_ALL partition(SYS_P11721) where rownum<2;

CTIME
------------
01-JUL-11

[oracle@hou-test backup]$ expdp part/part directory=dump dumpfile=ANONYMOUSUSER_ALL_201106-201207.dmp tables=ANONYMOUSUSER_ALL:SYS_P11720,ANONYMOUSUSER_ALL:SYS_P11721

Export: Release 11.1.0.6.0 - 64bit Production on Monday, 23 July, 2012 7:39:03

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "PART"."SYS_EXPORT_TABLE_01":  part/******** directory=dump dumpfile=ANONYMOUSUSER_ALL_201106-201207.dmp tables=ANONYMOUSUSER_ALL:SYS_P11720,ANONYMOUSUSER_ALL:SYS_P11721
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 9 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11720"     3.903 MB   25240 rows
. . exported "PART"."ANONYMOUSUSER_ALL":"SYS_P11721"     2.788 MB   17762 rows
Master table "PART"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for PART.SYS_EXPORT_TABLE_01 is:
  /home/oracle/backup/ANONYMOUSUSER_ALL_201106-201207.dmp
Job "PART"."SYS_EXPORT_TABLE_01" successfully completed at 07:39:25

 
三、还原
1.分区表整表还原
[oracle@hou-test backup]$ impdp part/part directory=dump dumpfile=ANONYMOUSUSER_ALL.dmp tables=part.ANONYMOUSUSER_ALL

Import: Release 11.1.0.6.0 - 64bit Production on Monday, 23 July, 2012 11:54:54

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "PART"."SYS_IMPORT_TABLE_15" successfully loaded/unloaded
Starting "PART"."SYS_IMPORT_TABLE_15":  part/******** directory=dump dumpfile=ANONYMOUSUSER_ALL.dmp tables=part.ANONYMOUSUSER_ALL
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39126: Worker unexpected fatal error in KUPW$WORKER.PUT_DDLS []
ORA-06502: PL/SQL: numeric or value error
LPX-00225: end-element tag "INSERT_TS_LIST_ITEM" does not match start-element tag "INTERVAL_STR"

ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.KUPW$WORKER", line 7704

----- PL/SQL Call Stack -----
  object      line  object
  handle    number  name
0x117526e10     18051  package body SYS.KUPW$WORKER
0x117526e10      7736  package body SYS.KUPW$WORKER
0x117526e10     15263  package body SYS.KUPW$WORKER
0x117526e10      3766  package body SYS.KUPW$WORKER
0x117526e10      8370  package body SYS.KUPW$WORKER
0x11725f6a8         1  anonymous block
0x1179235f8      1501  package body SYS.DBMS_SQL
0x117526e10      8201  package body SYS.KUPW$WORKER
0x117526e10      1477  package body SYS.KUPW$WORKER
0x10cd8ef10         2  anonymous block

ORA-39126: Worker unexpected fatal error in KUPW$WORKER.PUT_DDLS []
ORA-06502: PL/SQL: numeric or value error
LPX-00225: end-element tag "INSERT_TS_LIST_ITEM" does not match start-element tag "INTERVAL_STR"

ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.KUPW$WORKER", line 7704

----- PL/SQL Call Stack -----
  object      line  object
  handle    number  name
0x117526e10     18051  package body SYS.KUPW$WORKER
0x117526e10      7736  package body SYS.KUPW$WORKER
0x117526e10     15263  package body SYS.KUPW$WORKER
0x117526e10      3766  package body SYS.KUPW$WORKER
0x117526e10      8370  package body SYS.KUPW$WORKER
0x117506638         1  anonymous block
0x1179235f8      1501  package body SYS.DBMS_SQL
0x117526e10      8201  package body SYS.KUPW$WORKER
0x117526e10      1477  package body SYS.KUPW$WORKER
0x10cd8ef10         2  anonymous block

Job "PART"."SYS_IMPORT_TABLE_15" stopped due to fatal error at 11:54:55

还原出错,通过metalink查到原因,这是11.1.0.6.0版本bug,升级到11.1.0.7.0能解决这个问题,但是生产库就是这个版本,不允许升级。
 
 
看来只有放弃interval partition方案了。
 
https://support.oracle.com/epmos/faces/MosIndex.jspx?_afrLoop=191728917348427&_afrWindowMode=0&_adf.ctrl-state=19mdpcicai_4
 
使用普通range分区,每个月一个分区,每个分区在一个表空间上
一、准备普通range分区表
创建表空间
2011-05
2011-06
2011-07
2011-08
2011-09
2011-10
2011-11
2011-12
2012-01
2012-02
2012-03
2012-04
2012-05
2012-06
2012-07
 
创建表空间
create tablespace p6 datafile '/u01/app/oradata/hou/p6.dbf' size 10M autoextend on next 10M maxsize 31G;
create tablespace p7 datafile '/u01/app/oradata/hou/p7.dbf' size 10M autoextend on next 10M maxsize 31G;
create tablespace p8 datafile '/u01/app/oradata/hou/p8.dbf' size 10M autoextend on next 10M maxsize 31G;
create tablespace p9 datafile '/u01/app/oradata/hou/p9.dbf' size 10M autoextend on next 10M maxsize 31G;
create tablespace p10 datafile '/u01/app/oradata/hou/p10.dbf' size 10M autoextend on next 10M maxsize 31G;
create tablespace p11 datafile '/u01/app/oradata/hou/p11.dbf' size 10M autoextend on next 10M maxsize 31G;
create tablespace p12 datafile '/u01/app/oradata/hou/p12.dbf' size 10M autoextend on next 10M maxsize 31G;
create tablespace p13 datafile '/u01/app/oradata/hou/p13.dbf' size 10M autoextend on next 10M maxsize 31G;
create tablespace p14 datafile '/u01/app/oradata/hou/p14.dbf' size 10M autoextend on next 10M maxsize 31G;
create tablespace p15 datafile '/u01/app/oradata/hou/p15.dbf' size 10M autoextend on next 10M maxsize 31G;

授予part用户使用表空间权限
SQL> select 'alter user part quota unlimited on '|| TABLESPACE_NAME||';' from dba_tablespaces where TABLESPACE_NAME like 'P%';

'ALTERUSERPARTQUOTAUNLIMITEDON'||TABLESPACE_NAME||';'
------------------------------------------------------------------
alter user part quota unlimited on P1;
alter user part quota unlimited on P10;
alter user part quota unlimited on P11;
alter user part quota unlimited on P12;
alter user part quota unlimited on P13;
alter user part quota unlimited on P14;
alter user part quota unlimited on P15;
alter user part quota unlimited on P2;
alter user part quota unlimited on P3;
alter user part quota unlimited on P4;
alter user part quota unlimited on P5;
alter user part quota unlimited on P6;
alter user part quota unlimited on P7;
alter user part quota unlimited on P8;
alter user part quota unlimited on P9;

 
 
建分区表
CREATE TABLE "ANONYMOUSUSER_ALL"
  (
    "ID" NUMBER,
    "MD5ID" NVARCHAR2(32),
    "CTIME" DATE,
    "UTIME" DATE,
    "CLIENT_TYPE" NVARCHAR2(10),
    "CHANNEL" NVARCHAR2(20),
    "SUB_CHANNEL" NVARCHAR2(20),
    "TYPE" NVARCHAR2(10),
    "PHONENUM" NVARCHAR2(20),
    "PRODUCT_ID" NUMBER,
    "CLIENT_ID"  NUMBER,
    "IP"         NUMBER,
    "IMEI" NVARCHAR2(20),
    "UA" NVARCHAR2(100),
    "SCREEN_SIZE" NUMBER,
    CONSTRAINT "ANONYMOUSUSER_ADPLAN_PK" PRIMARY KEY ("ID")
  )
  partition by range(ctime)
(partition anony_all_2011_05 values less than (to_date('2011-06-01','yyyy-mm-dd')) tablespace p1,
partition anony_all_2011_06 values less than (to_date('2011-07-01','yyyy-mm-dd'))  tablespace p2,
partition anony_all_2011_07 values less than (to_date('2011-08-01','yyyy-mm-dd'))  tablespace p3,
partition anony_all_2011_08 values less than (to_date('2011-09-01','yyyy-mm-dd'))  tablespace p4,
partition anony_all_2011_09 values less than (to_date('2011-10-01','yyyy-mm-dd'))  tablespace p5,
partition anony_all_2011_10 values less than (to_date('2011-11-01','yyyy-mm-dd'))  tablespace p6,
partition anony_all_2011_11 values less than (to_date('2011-12-01','yyyy-mm-dd'))  tablespace p7,
partition anony_all_2011_12 values less than (to_date('2012-01-01','yyyy-mm-dd'))  tablespace p8,
partition anony_all_2012_01 values less than (to_date('2012-02-01','yyyy-mm-dd'))  tablespace p9,
partition anony_all_2012_02 values less than (to_date('2012-03-01','yyyy-mm-dd'))  tablespace p10,
partition anony_all_2012_03 values less than (to_date('2012-04-01','yyyy-mm-dd'))  tablespace p11,
partition anony_all_2012_04 values less than (to_date('2012-05-01','yyyy-mm-dd'))  tablespace p12,
partition anony_all_2012_05 values less than (to_date('2012-06-01','yyyy-mm-dd'))  tablespace p13,
partition anony_all_2012_06 values less than (to_date('2012-07-01','yyyy-mm-dd'))  tablespace p14,
partition anony_all_2012_07 values less than (to_date('2012-08-01','yyyy-mm-dd'))  tablespace p15
  );
 
 
 
SQL> select TABLE_NAME,PARTITION_NAME,HIGH_VALUE,PARTITION_POSITION,TABLESPACE_NAME from user_tab_partitions where TABLE_NAME='ANONYMOUSUSER_ALL';

TABLE_NAME          PARTITION_NAME              HIGH_VALUE                                                  PARTITION_POSITION TABLESPACE_NAME
-------------------- ------------------------------ -------------------------------------------------------------------------------- ------------------ ------------------------------
ANONYMOUSUSER_ALL    ANONY_ALL_2011_05              TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA                1 P1
ANONYMOUSUSER_ALL    ANONY_ALL_2011_06              TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA                2 P2
ANONYMOUSUSER_ALL    ANONY_ALL_2011_07              TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA                3 P3
ANONYMOUSUSER_ALL    ANONY_ALL_2011_08              TO_DATE(' 2011-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA                4 P4
ANONYMOUSUSER_ALL    ANONY_ALL_2011_09              TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA                5 P5
ANONYMOUSUSER_ALL    ANONY_ALL_2011_10              TO_DATE(' 2011-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA                6 P6
ANONYMOUSUSER_ALL    ANONY_ALL_2011_11              TO_DATE(' 2011-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA                7 P7
ANONYMOUSUSER_ALL    ANONY_ALL_2011_12              TO_DATE(' 2012-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA                8 P8
ANONYMOUSUSER_ALL    ANONY_ALL_2012_01              TO_DATE(' 2012-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA                9 P9
ANONYMOUSUSER_ALL    ANONY_ALL_2012_02              TO_DATE(' 2012-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA               10 P10
ANONYMOUSUSER_ALL    ANONY_ALL_2012_03              TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA               11 P11
ANONYMOUSUSER_ALL    ANONY_ALL_2012_04              TO_DATE(' 2012-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA               12 P12
ANONYMOUSUSER_ALL    ANONY_ALL_2012_05              TO_DATE(' 2012-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA               13 P13
ANONYMOUSUSER_ALL    ANONY_ALL_2012_06              TO_DATE(' 2012-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA               14 P14
ANONYMOUSUSER_ALL    ANONY_ALL_2012_07              TO_DATE(' 2012-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA               15 P15

15 rows selected.

 
插入数据
declare
i number:=1;
begin
for rec in (select * from ANONYMOUSUSER_ANDROID ) loop
insert into ANONYMOUSUSER_ALL values rec;
if mod(i,10000) =0 then
commit;
end if;
i:=i+1;
end loop;
commit;
end;

/

 
 
 
SQL> exec DBMS_STATS.GATHER_TABLE_STATS(user,'ANONYMOUSUSER_ALL');

PL/SQL procedure successfully completed.

 
分区中都有数据了
SQL> select TABLE_NAME,PARTITION_NAME,HIGH_VALUE,TABLESPACE_NAME,NUM_ROWS from user_tab_partitions where table_name='ANONYMOUSUSER_ALL';

TABLE_NAME          PARTITION_NAME              HIGH_VALUE                                                  TABLESPACE_NAME                NUM_ROWS
-------------------- ------------------------------ -------------------------------------------------------------------------------- ------------------------------ ----------
ANONYMOUSUSER_ALL    ANONY_ALL_2011_05              TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P1                     18465
ANONYMOUSUSER_ALL    ANONY_ALL_2011_06              TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P2                     25240
ANONYMOUSUSER_ALL    ANONY_ALL_2011_07              TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P3                     17762
ANONYMOUSUSER_ALL    ANONY_ALL_2011_08              TO_DATE(' 2011-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P4                     45357
ANONYMOUSUSER_ALL    ANONY_ALL_2011_09              TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P5                     55854
ANONYMOUSUSER_ALL    ANONY_ALL_2011_10              TO_DATE(' 2011-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P6                     83637
ANONYMOUSUSER_ALL    ANONY_ALL_2011_11              TO_DATE(' 2011-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P7                     88534
ANONYMOUSUSER_ALL    ANONY_ALL_2011_12              TO_DATE(' 2012-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P8                     56809
ANONYMOUSUSER_ALL    ANONY_ALL_2012_01              TO_DATE(' 2012-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P9                     108626
ANONYMOUSUSER_ALL    ANONY_ALL_2012_02              TO_DATE(' 2012-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P10                    70963
ANONYMOUSUSER_ALL    ANONY_ALL_2012_03              TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P11                    29288
ANONYMOUSUSER_ALL    ANONY_ALL_2012_04              TO_DATE(' 2012-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P12                    44022
ANONYMOUSUSER_ALL    ANONY_ALL_2012_05              TO_DATE(' 2012-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P13                    39730
ANONYMOUSUSER_ALL    ANONY_ALL_2012_06              TO_DATE(' 2012-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P14                    36423
ANONYMOUSUSER_ALL    ANONY_ALL_2012_07              TO_DATE(' 2012-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA P15                    23010

 
 
二、备份
1.分区表整表备份还原
1.1 分区表全表备份
[oracle@hou-test backup]$ exp part/part file= ANONYMOUSUSER_ALL.dmp tables=ANONYMOUSUSER_ALL

Export: Release 11.1.0.6.0 - Production on Mon Jul 23 13:03:15 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table              ANONYMOUSUSER_ALL
. . exporting partition              ANONY_ALL_2011_05      18465 rows exported
. . exporting partition              ANONY_ALL_2011_06      25240 rows exported
. . exporting partition              ANONY_ALL_2011_07      17762 rows exported
. . exporting partition              ANONY_ALL_2011_08      45357 rows exported
. . exporting partition              ANONY_ALL_2011_09      55854 rows exported
. . exporting partition              ANONY_ALL_2011_10      83637 rows exported
. . exporting partition              ANONY_ALL_2011_11      88534 rows exported
. . exporting partition              ANONY_ALL_2011_12      56809 rows exported
. . exporting partition              ANONY_ALL_2012_01     108626 rows exported
. . exporting partition              ANONY_ALL_2012_02      70963 rows exported
. . exporting partition              ANONY_ALL_2012_03      29288 rows exported
. . exporting partition              ANONY_ALL_2012_04      44022 rows exported
. . exporting partition              ANONY_ALL_2012_05      39730 rows exported
. . exporting partition              ANONY_ALL_2012_06      36423 rows exported
. . exporting partition              ANONY_ALL_2012_07      23010 rows exported
Export terminated successfully without warnings.

 
1.2 分区表全表还原

SQL> drop table ANONYMOUSUSER_ALL;

 
imp导入
[oracle@hou-test backup]$ imp part/part file=ANONYMOUSUSER_ALL.dmp tables=ANONYMOUSUSER_ALL

Import: Release 11.1.0.6.0 - Production on Mon Jul 23 13:06:13 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT:V11.01.00 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing PART's objects into PART
. importing PART's objects into PART
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_05"      18465 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_06"      25240 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_07"      17762 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_08"      45357 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_09"      55854 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_10"      83637 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_11"      88534 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_12"      56809 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2012_01"     108626 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2012_02"      70963 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2012_03"      29288 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2012_04"      44022 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2012_05"      39730 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2012_06"      36423 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2012_07"      23010 rows imported
Import terminated successfully without warnings.

 
 
2.分区表一个分区的备份还原
2.1备份一个分区
比如备份ANONY_ALL_2011_05分区
[oracle@hou-test backup]$ exp part/part file=ANONYMOUSUSER_ALL-ANONY_ALL_2011_05.dmp tables=ANONYMOUSUSER_ALL:ANONY_ALL_2011_05

Export: Release 11.1.0.6.0 - Production on Mon Jul 23 13:16:07 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table              ANONYMOUSUSER_ALL
. . exporting partition              ANONY_ALL_2011_05      18465 rows exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
Export terminated successfully with warnings.

 
导出时报错,解决办法1:
指定Linux系统的NLS_LANG环境变量为数据库的数据集
SQL>  select userenv('language') from dual;

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK

 
[oracle@hou-test backup]$ set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
[oracle@hou-test backup]$ export set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
 
 
再次导出
[oracle@hou-test backup]$ exp part/part file=ANONYMOUSUSER_ALL-ANONY_ALL_2011_05.dmp tables=ANONYMOUSUSER_ALL:ANONY_ALL_2011_05

Export: Release 11.1.0.6.0 - Production on Mon Jul 23 13:16:07 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table              ANONYMOUSUSER_ALL
. . exporting partition              ANONY_ALL_2011_05      18465 rows exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
Export terminated successfully with warnings.

 
依然报错,看来不大适用分区表
 
解决办法2:使用statistics=none,也就是不导出统计信息。
[oracle@hou-test backup]$ exp part/part file=ANONYMOUSUSER_ALL-ANONY_ALL_2011_05.dmp tables=ANONYMOUSUSER_ALL:ANONY_ALL_2011_05 statistics=none

Export: Release 11.1.0.6.0 - Production on Mon Jul 23 13:40:34 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table              ANONYMOUSUSER_ALL
. . exporting partition              ANONY_ALL_2011_05      18465 rows exported
Export terminated successfully without warnings.

 
2.2还原一个分区
truncate ANONY_ALL_2011_05分区
SQL> alter table ANONYMOUSUSER_ALL truncate partition ANONY_ALL_2011_05 update indexes;

Table truncated.

 
还原
[oracle@hou-test backup]$ imp part/part file=ANONYMOUSUSER_ALL-ANONY_ALL_2011_05.dmp tables=ANONYMOUSUSER_ALL:ANONY_ALL_2011_05 ignore=y

Import: Release 11.1.0.6.0 - Production on Mon Jul 23 13:55:39 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT:V11.01.00 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing PART's objects into PART
. importing PART's objects into PART
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_05"      18465 rows imported
Import terminated successfully without warnings.

 
 
 
3.同时备份和还原多个分区
2.1备份多个分区,ANONYMOUSUSER_ALL的ANONY_ALL_2011_07和ANONY_ALL_2011_08分区。
[oracle@hou-test backup]$ exp part/part file=ANONY_ALL_2011_07-ANONY_ALL_2011_08.dmp tables=ANONYMOUSUSER_ALL:ANONY_ALL_2011_07,ANONYMOUSUSER_ALL:ANONY_ALL_2011_08  statistics=none

Export: Release 11.1.0.6.0 - Production on Mon Jul 23 14:02:38 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table              ANONYMOUSUSER_ALL
. . exporting partition              ANONY_ALL_2011_07      17762 rows exported
. . exporting partition              ANONY_ALL_2011_08      45357 rows exported
Export terminated successfully without warnings.

 
2.2导入多个分区
truncate这两个分区
SQL> alter table ANONYMOUSUSER_ALL truncate partition ANONY_ALL_2011_07 update indexes;

Table truncated.

SQL> alter table ANONYMOUSUSER_ALL truncate partition ANONY_ALL_2011_08 update indexes;

Table truncated.

 
导入
[oracle@hou-test backup]$ imp part/part file=ANONY_ALL_2011_07-ANONY_ALL_2011_08.dmp tables=ANONYMOUSUSER_ALL:ANONY_ALL_2011_07,ANONYMOUSUSER_ALL:ANONY_ALL_2011_08 ignore=y

Import: Release 11.1.0.6.0 - Production on Mon Jul 23 14:15:29 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT:V11.01.00 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing PART's objects into PART
. importing PART's objects into PART
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_07"      17762 rows imported
. . importing partition "ANONYMOUSUSER_ALL":"ANONY_ALL_2011_08"      45357 rows imported
Import terminated successfully without warnings.

Oracle 11.1.0.6 导入导出bug的更多相关文章

  1. Oracle 11.2.0.1的一个Bug,客户端报ORA-03113: 通信通道的文件结尾

    半小时前,一个项目反馈应用系统部分功能报错,ORA-03113: 通信通道的文件结尾.好像是个常见的错误. 异常信息:ORA-03113: 通信通道的文件结尾 进程 ID: 2392 会话 ID: 2 ...

  2. Oracle 11g 的bug?: aix 上,expdp 11.2.0.1 导出,impdp 11.2.0.3 导入,Interval 分区的 【Interval】 分区属性成了【N】

    如题: Oracle 11g 的bug?: aix 上,expdp 11.2.0.1 导出,impdp 11.2.0.3 导入,Interval 分区的 [Interval] 分区属性成了[N] 谨记 ...

  3. centos6.5 x86_64安装oracle 11.2.0.3grid

     centos6.5 x86_64安装oracle 11.2.0.3grid 1.安装前的准备 工作 1.1.配置node1 1.1.1.配置虚拟机并安装centos 安装node1----- 1 ...

  4. Oracle 11.2.0.1 ADG环境MRP进程遭遇ORA-600异常终止

    环境:Linux + Oracle 11.2.0.1 ADG 现象:发现备库没有应用日志 1. 数据库查询备库目前状态 发现备库目前没有应用日志,apply lag已经显示备库有3天21小时多没有应用 ...

  5. oracle 11.2.0.2以后对数据库用户名重命名

    本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn [转自]http://www.xifenfei.com/2012/0 ...

  6. CentOS 7 安装 Oracle 11.2.0.4

    一.安装环境 CentOS Linux release 7.2.1511 (Core) Oracle Database 11g Release 2 (11.2.0.4) 二.安装前准备 2.1 修改主 ...

  7. 【原】Oracle 11.2.0.1 64bit for RHEL6.0 Server x86_64 静默安装

    作者:david_zhang@sh [转载时请以超链接形式标明文章] 链接:http://www.cnblogs.com/david-zhang-index/p/4182469.html 本文适用Or ...

  8. Oracle 11.2.0.1 ADG环境MRP进程遭遇ORA

    环境:Linux + Oracle 11.2.0.1 ADG现象:发现备库没有应用日志 1. 数据库查询备库目前状态发现备库目前没有应用日志,apply lag已经显示备库有3天21小时多没有应用日志 ...

  9. oracle 11.2.0.4静默安装

    oracle 11.2.0.4静默安装 1.安装包 1.1.上传安装包 xshell可用rz命令,选择安装包. mobaxterm可用左侧栏上传功能. 2.安装准备 2.1.关闭防火墙.SELinux ...

随机推荐

  1. openstack、kvm、qemu-kvm、libvirt、xen的关系

    虚拟化技术—基础(1) 本文围绕下面3个问题进行对虚拟化技术展开讨论: 1.虚拟化技术实现方式有哪些?虚拟化技术分哪些? 2.请分别通过kvm.xen工具来实现虚拟化系统的部署? 3.请描述opens ...

  2. 转 LIST INCARNATION OF DATABASE

    incarnation在英文中是“化身”的意思. 那么在oracle中,它又是什么意思呢?有什么作用呢? 我们看一些基本概念 Current Incarnation(当前化身):数据库当前正在使用的化 ...

  3. 多重if 与 switch case的区别

    多重if:可以做等值操作也可以做区间操作 switch case:只能做等值操作

  4. (转)同步异步,阻塞非阻塞 和nginx的IO模型

    同步异步,阻塞非阻塞 和nginx的IO模型  原文:https://www.cnblogs.com/wxl-dede/p/5134636.html 同步与异步 同步和异步关注的是消息通信机制 (sy ...

  5. C#DataTable与Model互转

    /// <summary> /// 实体转换辅助类 /// </summary> public class ModelConvertHelper<T> where ...

  6. console命令详解:(转载学习)

    Console命令详解,让调试js代码变得更简单   Firebug是网页开发的利器,能够极大地提升工作效率. 但是,它不太容易上手.我曾经翻译过一篇<Firebug入门指南>,介绍了一些 ...

  7. 【ExtJS】关于constructor、initComponent、beforeRender

    ExtJS提供的组件非常丰富,不过当原生的组件无法满足要求时,就需要扩展原生自定义组件了. initComponent 和 constructor 就是Extjs 提供用来实现继承和扩展的方式. 在E ...

  8. c#输入方法名来调用方法(反射)

    using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Sy ...

  9. 字典表+委托替代switch解决思路

    参考:http://www.jianshu.com/p/8887b3b3e8ba 代码 namespace 解决Switch { class Program { delegate string fun ...

  10. 九度oj题目1153:括号匹配问题

    题目1153:括号匹配问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4866 解决:2112 题目描述: 在某个字符串(长度不超过100)中有左括号.右括号和大小写字母:规定(与常见 ...