导入导出 Oracle 分区表数据

简介: --****************************-- 导入导出 Oracle 分区表数据--****************************        导入导入Oracle 分区表数据是Oracle DBA 经常完成的任务之一。

--****************************

-- 导入导出 Oracle 分区表数据

--****************************

   

    导入导入Oracle 分区表数据是Oracle DBA 经常完成的任务之一。分区表的导入导出同样普通表的导入导出方式,只不过导入导出需要考

虑到分区的特殊性,如分区索引,将分区迁移到普通表,或使用原始分区表导入到新的分区表。下面将描述使用imp/expimpdp/expdp导入导出

分区表数据。

 

    有关分区表的特性请参考: 

        Oracle 分区表

        SQL server 2005 切换分区表

        SQL server 2005 基于已存在的表创建分区

 

    有关导入导出工具请参考:

        数据泵EXPDP 导出工具的使用

        数据泵IMPDP 导入工具的使用

 

    有关导入导出的官方文档请参考:

        Original Export and Import     

 

一、分区级别的导入导出

    可以导出一个或多个分区,也可以导出所有分区(即整个表)

    可以导入所有分区(即整个表),一个或多个分区以及子分区。

    对于已经存在数据的表,使用imp导入时需要使用参数IGNORE=y,而使用impdp,加table_exists_action=append | replace 参数。

 

二、创建演示环境

    1.查看当前数据库的版本

        SQL> select * from v$version where rownum < 2;

 

        BANNER

        --------------------------------------------------------------------------------

        Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

 

    2.创建一个分区表

        SQL> alter session set nls_date_format='yyyy-mm-dd';

 

        SQL> CREATE TABLE tb_pt (

        sal_date   DATE NOT NULL,

        sal_id NUMBER NOT NULL,

        sal_row    NUMBER(12) NOT NULL)

        partition by range(sal_date)

        (

        partition sal_11 values less than(to_date('2012-01-01','YYYY-MM-DD')) ,

        partition sal_12 values less than(to_date('2013-01-01','YYYY-MM-DD')) ,

        partition sal_13 values less than(to_date('2014-01-01','YYYY-MM-DD')) ,

        partition sal_14 values less than(to_date('2015-01-01','YYYY-MM-DD')) ,

        partition sal_15 values less than(to_date('2016-01-01','YYYY-MM-DD')) ,

        partition sal_16 values less than(to_date('2017-01-01','YYYY-MM-DD')) ,

        partition sal_other values less than (maxvalue)

        ) nologging;

 

    3.创建一个唯一索引

        CREATE UNIQUE INDEX tb_pt_ind1

        ON tb_pt(sal_date) nologging;

   

    4.为分区表生成数据

        SQL> INSERT INTO tb_pt

        SELECT TRUNC(SYSDATE)+ROWNUM, dbms_random.random, ROWNUM

        FROM dual

        CONNECT BY LEVEL<=5000;

 

        SQL> commit;

 

        SQL> select count(1) from tb_pt partition(sal_11);

 

          COUNT(1)

        ----------

               300

 

        SQL> select count(1) from tb_pt partition(sal_other);

 

          COUNT(1)

        ----------

              2873

 

        SQL> select * from tb_pt partition(sal_12) where rownum < 3;

 

        SAL_DATE      SAL_ID    SAL_ROW

        --------- ---------- ----------

        01-JAN-12 -1.356E+09        301

        02-JAN-12 -761530183        302

 

三、使用exp/imp导出导入分区表数据

    1.导出整个分区表

   

        [oracle@node1 ~]$ exp scott/tiger file='/u02/dmp/tb_pt.dmp' log='/u02/dmp/tb_pt.log' tables=tb_pt

        Export: Release 11.2.0.1.0 - Production on Wed Mar 9 13:52:18 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing o

        Export done in US7ASCII character set and AL16UTF16 NCHAR character set

        server uses ZHS16GBK character set (possible charset conversion)

        About to export specified tables via Conventional Path ...

        . . exporting table                          TB_PT

        . . exporting partition                         SAL_11        300 rows exported

        . . exporting partition                         SAL_12        366 rows exported

        . . exporting partition                         SAL_13        365 rows exported

        . . exporting partition                         SAL_14        365 rows exported

        . . exporting partition                         SAL_15        365 rows exported

        . . exporting partition                         SAL_16        366 rows exported

        . . exporting partition                      SAL_OTHER       2873 rows exported

        EXP-00091: Exporting questionable statistics.

        EXP-00091: Exporting questionable statistics.

        Export terminated successfully with warnings.

       

        [oracle@node1 ~]$ oerr exp 00091

        00091, 00000, "Exporting questionable statistics."

        // *Cause:  Export was able export statistics, but the statistics may not be

        //          usuable. The statistics are questionable because one or more of

        //          the following happened during export: a row error occurred, client

        //          character set or NCHARSET does not match with the server, a query

        //          clause was specified on export, only certain partitions or

        //          subpartitions were exported, or a fatal error occurred while

        //          processing a table.

        // *Action: To export non-questionable statistics, change the client character

        //          set or NCHARSET to match the server, export with no query clause,

        //          export complete tables. If desired, import parameters can be

        //          supplied so that only non-questionable statistics will be imported,

        //          and all questionable statistics will be recalculated.

 

        在上面的导出中出现了错误提示,即EXP-00091,该错误表明exp工具所在的环境变量中的NLS_LANGDB中的NLS_CHARACTERSET不一致

        尽管该错误对最终的数据并无影响,但调整该参数来避免异常还是有必要的。因此需要将其设置为一致即可解决上述的错误提示。

       

        SQL> select userenv('language') from dual;

 

        USERENV('LANGUAGE')

        ----------------------------------------------------

        AMERICAN_AMERICA.ZHS16GBK

 

        [oracle@node1 ~]$ export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK'   

 

        经过上述设置之后再次导出正常,过程略。

 

    2.导出单个分区

 

        [oracle@node1 ~]$ exp scott/tiger file='/u02/dmp/tb_pt_sal_16.dmp' log='/u02/dmp/tb_pt_sal_16.log' tables=tb_pt:sal_16

        Export: Release 11.2.0.1.0 - Production on Wed Mar 9 13:52:38 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing o

        Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

        About to export specified tables via Conventional Path ...

        . . exporting table                          TB_PT

        . . exporting partition                         SAL_16        366 rows exported

        EXP-00091: Exporting questionable statistics.

        EXP-00091: Exporting questionable statistics.

        Export terminated successfully with warnings

 

        在上面的导出过程中再次出现了统计信息错误的情况,因此采取了对该对象收集统计信息,但并不能解决该错误,但在exp命令行中增

        statistics=none即可,如下:

        [oracle@node1 ~]$ exp scott/tiger file='/u02/dmp/tb_pt_sal_16.dmp' log='/u02/dmp/tb_pt_sal_16.log' /

        > tables=tb_pt:sal_16 statistics=none

 

        如果要导出多个分区,则在tables参数中增加分区数。如:tables=(tb_pt:sal_15,tb_pt:sal_16)

 

    3.使用imp工具生成创建分区表的DDL语句

        [oracle@node1 ~]$ imp scott/tiger tables=tb_pt indexfile='/u02/dmp/cr_tb_pt.sql' /

        > file='/u02/dmp/tb_pt.dmp' ignore=y

        Export: Release 11.2.0.1.0 - Production on Wed Mar 9 13:54:38 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing o

        Export file created by EXPORT:V11.02.00 via conventional path

        import done in US7ASCII character set and AL16UTF16 NCHAR character set

        import server uses ZHS16GBK character set (possible charset conversion)

        . . skipping partition "TB_PT":"SAL_11"                  

        . . skipping partition "TB_PT":"SAL_12"                  

        . . skipping partition "TB_PT":"SAL_13"                  

        . . skipping partition "TB_PT":"SAL_14"                  

        . . skipping partition "TB_PT":"SAL_15"                  

        . . skipping partition "TB_PT":"SAL_16"                  

        . . skipping partition "TB_PT":"SAL_OTHER"               

        Import terminated successfully without warnings.

 

    4.导入单个分区(使用先前备份的单个分区导入文件)

        SQL> alter table tb_pt truncate partition sal_16;   --导入前先将分区实现truncate

 

        Table truncated.

 

        SQL> select count(1) from tb_pt partition(sal_16);

 

          COUNT(1)

        ----------

                 0

 

        SQL> ho imp scott/tiger tables=tb_pt:sal_16 file='/u02/dmp/tb_pt_sal_16.dmp' ignore=y

        Export: Release 11.2.0.1.0 - Production on Wed Mar 9 13:55:39 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing o

        Export file created by EXPORT:V11.02.00 via conventional path

        import done in US7ASCII character set and AL16UTF16 NCHAR character set

        import server uses ZHS16GBK character set (possible charset conversion)

        . importing SCOTT's objects into SCOTT

        . importing SCOTT's objects into SCOTT

        . . importing partition               "TB_PT":"SAL_16"

        IMP-00058: ORACLE error 1502 encountered

        ORA-01502: index 'SCOTT.TB_PT_IND1' or partition of such index is in unusable state

        Import terminated successfully with warnings.

 

        收到了ORA-01502错误,下面查看索引的状态,并对其重建索引后再执行导入

        SQL> select index_name ,status from dba_indexes where table_name='TB_PT';  --查看索引的状态

 

        INDEX_NAME                     STATUS

        ------------------------------ --------

        TB_PT_IND1                     UNUSABLE

 

        SQL> alter index TB_PT_IND1 rebuild online;                --重建索引

 

        Index altered.

 

        SQL> ho imp scott/tiger tables=tb_pt:sal_16 file='/u02/dmp/tb_pt_sal_16.dmp' ignore=y  --再次导入成功

        Export: Release 11.2.0.1.0 - Production on Wed Mar 9 13:56:15 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing o

        Export file created by EXPORT:V11.02.00 via conventional path

        import done in US7ASCII character set and AL16UTF16 NCHAR character set

        import server uses ZHS16GBK character set (possible charset conversion)

        . importing SCOTT's objects into SCOTT

        . importing SCOTT's objects into SCOTT

        . . importing partition               "TB_PT":"SAL_16"        366 rows imported

        Import terminated successfully without warnings.

       

        SQL> select count(*) from tb_pt partition(sal_16);

 

          COUNT(*)

        ----------

               366

 

    5.导入整个表

        SQL> truncate table tb_pt;    --首先truncate 整个表

 

        Table truncated.

 

        SQL> ho imp scott/tiger tables=tb_pt file='/u02/dmp/tb_pt.dmp' ignore=y indexes=y

        Export: Release 11.2.0.1.0 - Production on Wed Mar 9 13:57:10 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing o

        Export file created by EXPORT:V11.02.00 via conventional path

        import done in US7ASCII character set and AL16UTF16 NCHAR character set

        import server uses ZHS16GBK character set (possible charset conversion)

        . importing SCOTT's objects into SCOTT

        . importing SCOTT's objects into SCOTT

        . . importing partition               "TB_PT":"SAL_11"        298 rows imported

        . . importing partition               "TB_PT":"SAL_12"        366 rows imported

        . . importing partition               "TB_PT":"SAL_13"        365 rows imported

        . . importing partition               "TB_PT":"SAL_14"        365 rows imported

        . . importing partition               "TB_PT":"SAL_15"        365 rows imported

        . . importing partition               "TB_PT":"SAL_16"        366 rows imported

        . . importing partition            "TB_PT":"SAL_OTHER"       2875 rows imported

        Import terminated successfully without warnings.

       

        SQL> select count(1) from tb_pt partition(sal_other);

 

          COUNT(1)

        ----------

              2875

 

四、使用expdp/impdb来实现分区表的导入导出

    1.查看导入导出的目录设置

        SQL> select directory_name,directory_path from dba_directories where directory_name='DMP';

 

        DIRECTORY_NAME                 DIRECTORY_PATH

        ------------------------------ ------------------------------------------------------------

        DMP                            /u02/dmp

 

    2.为分区表创建一个本地索引

        create index tb_pt_local_idx

        on tb_pt(sal_id)

        local

        (partition local1,

        partition local2,

        partition local3,

        partition local4,

        partition local5,

        partition local6,

        partition local7)

        ;

 

    3.导出整个表

        [oracle@node1 ~]$ expdp scott/tiger directory=dmp dumpfile=tb_pt.dmp logfile=tb_pb.log tables=tb_pt parallel=3

        Export: Release 11.2.0.1.0 - Production on Wed Mar 9 14:04:28 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing options

        Starting "SCOTT"."SYS_EXPORT_TABLE_01":  scott/******** directory=dmp dumpfile=tb_pt.dmp logfile=tb_pb.log tables=

            tb_pt parallel=3                                                                  

        Estimate in progress using BLOCKS method...

        Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

        Total estimation using BLOCKS method: 512 KB

        . . exported "SCOTT"."TB_PT":"SAL_OTHER"                 71.63 KB    2875 rows

        . . exported "SCOTT"."TB_PT":"SAL_11"                    12.54 KB     298 rows

        . . exported "SCOTT"."TB_PT":"SAL_12"                    14.22 KB     366 rows

        . . exported "SCOTT"."TB_PT":"SAL_13"                    14.18 KB     365 rows

        . . exported "SCOTT"."TB_PT":"SAL_14"                    14.18 KB     365 rows

        . . exported "SCOTT"."TB_PT":"SAL_15"                    14.19 KB     365 rows

        . . exported "SCOTT"."TB_PT":"SAL_16"                    14.23 KB     366 rows

        Processing object type TABLE_EXPORT/TABLE/TABLE

        Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

        Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

        Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

        Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

        Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded

        ******************************************************************************

        Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:

          /u02/dmp/tb_pt.dmp

        Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 14:04:51

 

    4.导出多个分区

        [oracle@node1 ~]$ expdp scott/tiger directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt.log /

        > tables=(tb_pt:sal_16,tb_pt:sal_other) parallel=2

        Export: Release 11.2.0.1.0 - Production on Wed Mar 9 14:08:06 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing options

        Starting "SCOTT"."SYS_EXPORT_TABLE_01":  scott/******** directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt.log

            tables=(tb_pt:sal_16,tb_pt:sal_other) parallel=2                        --*/

        Estimate in progress using BLOCKS method...

        Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

        Total estimation using BLOCKS method: 192 KB

        . . exported "SCOTT"."TB_PT":"SAL_OTHER"                 71.63 KB    2875 rows

        . . exported "SCOTT"."TB_PT":"SAL_16"                    14.23 KB     366 rows

        Processing object type TABLE_EXPORT/TABLE/TABLE

        Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

        Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

        Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

        Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

        Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded

        ******************************************************************************

        Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:

          /u02/dmp/tb_pts.dmp

        Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 14:08:17

 

    5.截断分区sal_other

        SQL> alter table tb_pt truncate partition(sal_other);

 

        Table truncated.

 

        SQL> select count(*) from tb_pt partition(sal_other);

 

          COUNT(*)

        ----------

                 0

 

        SQL> select index_name,status,partitioned from dba_indexes where table_name='TB_PT'; --查看索引的状态, TB_PT_IND1不可用

 

        INDEX_NAME                     STATUS   PAR

        ------------------------------ -------- ---

        TB_PT_IND1                     UNUSABLE NO

        TB_PT_LOCAL_IDX                N/A      YES

       

        SQL> select index_name ,partition_name, status from dba_ind_partitions where index_owner='SCOTT';

       

        INDEX_NAME                     PARTITION_NAME                 STATUS

        ------------------------------ ------------------------------ --------

        TB_PT_LOCAL_IDX                LOCAL1                         USABLE

        TB_PT_LOCAL_IDX                LOCAL2                         USABLE

        TB_PT_LOCAL_IDX                LOCAL3                         USABLE

        TB_PT_LOCAL_IDX                LOCAL4                         USABLE

        TB_PT_LOCAL_IDX                LOCAL5                         USABLE

        TB_PT_LOCAL_IDX                LOCAL6                         USABLE

        TB_PT_LOCAL_IDX                LOCAL7                         USABLE

       

    6.导入单个分区

        [oracle@node1 ~]$ impdp scott/tiger directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt_imp.log /

        > tables=tb_pt:sal_other skip_unusable_indexes=y table_exists_action=replace

        Import: Release 11.2.0.1.0 - Production on Wed Mar 9 14:13:28 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing options

        Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded

        Starting "SCOTT"."SYS_IMPORT_TABLE_01":  scott/******** directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt_imp.log

            tables=tb_pt:sal_other skip_unusable_indexes=y table_exists_action=replace             --*/

        Processing object type TABLE_EXPORT/TABLE/TABLE

        Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

        . . imported "SCOTT"."TB_PT":"SAL_OTHER"                 71.63 KB    2875 rows

        Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

        Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

        Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

        Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

        Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 14:13:33

 

        SQL> select index_name,status,partitioned from dba_indexes where table_name='TB_PT';

 

        INDEX_NAME                     STATUS   PAR

        ------------------------------ -------- ---

        TB_PT_IND1                     VALID    NO

        TB_PT_LOCAL_IDX                N/A      YES

       

        从上面的导入情况可以看出,尽管执行了truncate partition,然而使用impdp导入工具,并且使用参数table_exists_action=replace

        可以避免使用imp导入时唯一和主键索引需要重建的问题。注意,如果没有使用table_exists_action=replace参数,将会收到ORA-39151

        错误,如下

            ORA-39151: Table "SCOTT"."TB_PT" exists. All dependent metadata and data will be skipped due to

                table_exists_action of skip

 

    7.导入整个表

        [oracle@node1 ~]$ impdp scott/tiger directory=dmp dumpfile=tb_pt.dmp logfile=tb_pt_fullimp.log /

        > tables=tb_pt skip_unusable_indexes=y table_exists_action=replace

        Import: Release 11.2.0.1.0 - Production on Wed Mar 9 14:17:35 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing options

        Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded

        Starting "SCOTT"."SYS_IMPORT_TABLE_01":  scott/******** directory=dmp dumpfile=tb_pt.dmp logfile=tb_pt_fullimp.log

            tables=tb_pt skip_unusable_indexes=y table_exists_action=replace                     --*/

        Processing object type TABLE_EXPORT/TABLE/TABLE

        Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

        . . imported "SCOTT"."TB_PT":"SAL_OTHER"                 71.63 KB    2875 rows

        . . imported "SCOTT"."TB_PT":"SAL_11"                    12.54 KB     298 rows

        . . imported "SCOTT"."TB_PT":"SAL_12"                    14.22 KB     366 rows

        . . imported "SCOTT"."TB_PT":"SAL_13"                    14.18 KB     365 rows

        . . imported "SCOTT"."TB_PT":"SAL_14"                    14.18 KB     365 rows

        . . imported "SCOTT"."TB_PT":"SAL_15"                    14.19 KB     365 rows

        . . imported "SCOTT"."TB_PT":"SAL_16"                    14.23 KB     366 rows

        Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

        Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

        Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

        Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

        Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 14:17:40

 

五、参数skip_unusable_indexes的作用

    SQL> show parameter skip

 

    NAME                                 TYPE        VALUE

    ------------------------------------ ----------- ------------------------------

    skip_unusable_indexes                boolean     TRUE

 

    该参数允许在导入分区数据时延迟对索引的处理,即先将数据导入,导入后再来重建索引分区。

    在命令行导入中未指定导入参数skip_unusable_indexes时,则对于索引相关的问题,根据数据库初始化参数的值来确定。

    在命令行导入中如果指定了参数skip_unusable_indexes时,则该参数的值优先于数据库初始化参数的设定值。

    skip_unusable_indexes=yunique index不起作用,因为此时的unique index扮演者constraint的作用,所以在insert数据时index必须被

        更新。

    对于单个分区导入时PKunique index的处理,必须先重建索引然后进行导入。

    使用impdp数据泵实现导入并使用参数table_exists_action=replace可以解决上述问题,即ORA-01502错误。

 

六、更多参考

 

    有关性能优化请参考

        Oracle 硬解析与软解析

共享池的调整与优化(Shared pool Tuning)

Buffer cache 的调整与优化(一)

Oracle 表缓存(caching table)的使用

 

有关闪回特性请参考

        Oracle 闪回特性(FLASHBACK DATABASE)

Oracle 闪回特性(FLASHBACK DROP & RECYCLEBIN)

Oracle 闪回特性(Flashback Query、Flashback Table)

Oracle 闪回特性(Flashback Version、Flashback Transaction)

 

有关基于用户管理的备份和备份恢复的概念请参考:

        Oracle 冷备份

        Oracle 热备份

        Oracle 备份恢复概

        Oracle 实例恢复

        Oracle 基于用户管理恢复的处理(详细描述了介质恢复及其处理)

       

    有关RMAN的恢复与管理请参考:

        RMAN 概述及其体系结构

        RMAN 配置、监控与管理

        RMAN 备份详解

        RMAN 还原与恢复

       

    有关Oracle体系结构请参考:

        Oracle 实例和Oracle数据库(Oracle系结构)

        Oracle 表空间与数据文件

        Oracle 密码文件

        Oracle 参数文件

Oracle 数据库实例启动关闭过程

        Oracle 联机重做日志文件(ONLINE LOG FILE)

        Oracle 控制文件(CONTROLFILE)

        Oracle 归档日志

 

相关实践学习
数据库实验室挑战任务-初级任务
本场景介绍如何开通属于你的免费云数据库,在RDS-MySQL中完成对学生成绩的详情查询,执行指定类型SQL。
阿里云云原生数据仓库AnalyticDB MySQL版 使用教程
云原生数据仓库AnalyticDB MySQL版是一种支持高并发低延时查询的新一代云原生数据仓库,高度兼容MySQL协议以及SQL:92、SQL:99、SQL:2003标准,可以对海量数据进行即时的多维分析透视和业务探索,快速构建企业云上数据仓库。 了解产品 https://www.aliyun.com/product/ApsaraDB/ads
目录
相关文章
|
6天前
|
SQL 存储 Oracle
Oracle的PL/SQL定义变量和常量:数据的稳定与灵动
【4月更文挑战第19天】在Oracle PL/SQL中,变量和常量扮演着数据存储的关键角色。变量是可变的“魔术盒”,用于存储程序运行时的动态数据,通过`DECLARE`定义,可在循环和条件判断中体现其灵活性。常量则是不可变的“固定牌”,一旦设定值便保持不变,用`CONSTANT`声明,提供程序稳定性和易维护性。通过 `%TYPE`、`NOT NULL`等特性,可以更高效地管理和控制变量与常量,提升代码质量。善用两者,能优化PL/SQL程序的结构和性能。
|
6天前
|
Oracle 安全 关系型数据库
Oracle数据守卫(DG):数据的“守护者”与“时光机”
【4月更文挑战第19天】Oracle Data Guard保障数据安全,通过实时维护备库实现故障切换,保证业务连续性。它使用日志传输和应用保持数据同步,如同“时光机”,借助闪回技术能恢复误操作数据。此外,它还提供数据压缩、加密和故障转移等功能,提升数据库安全性与性能。作为数据管理员,理解并善用Data Guard是确保企业数据安全的关键。
|
6天前
|
存储 NoSQL Oracle
Oracle 12c的内存列存储:数据的“闪电侠”
【4月更文挑战第19天】Oracle 12c的内存列存储以超高速度革新数据处理,结合列存储与内存技术,实现快速查询与压缩。它支持向量化查询和并行处理,提升效率,但需合理配置以平衡系统资源。作为数据管理员,应善用此功能,适应业务需求和技术发展。
|
6天前
|
存储 Oracle 关系型数据库
Oracle 12c的多重索引:数据的“多维导航仪”
【4月更文挑战第19天】Oracle 12c的多重索引提升数据查询效率,如同多维导航仪。在同一表上创建针对不同列的多个索引,加速检索过程。虽然过多索引会增加存储和维护成本,但合理选择和使用索引策略,结合位图、函数索引等高级特性,能优化查询,应对复杂场景。数据管理员应善用这些工具,根据需求进行索引管理,支持企业数据分析。
|
6天前
|
存储 Oracle 数据管理
Oracle 12c的自动数据优化(ADO)与热图:数据管理的“瘦身”与“透视”艺术
【4月更文挑战第19天】Oracle 12c的ADO和热图技术革新数据管理。ADO智能清理无用数据,优化存储,提升查询速度,实现数据&quot;瘦身&quot;;热图则以直观的视觉表示展示数据分布和状态,助力识别性能瓶颈,犹如数据的&quot;透视&quot;工具。这两项技术结合,强化数据管理,为企业业务发展保驾护航。
|
6天前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL游标属性:数据的“导航仪”与“仪表盘”
【4月更文挑战第19天】Oracle PL/SQL游标属性如同车辆的导航仪和仪表盘,提供丰富信息和控制。 `%FOUND`和`%NOTFOUND`指示数据读取状态,`%ROWCOUNT`记录处理行数,`%ISOPEN`显示游标状态。还有`%BULK_ROWCOUNT`和`%BULK_EXCEPTIONS`增强处理灵活性。通过实例展示了如何在数据处理中利用这些属性监控和控制流程,提高效率和准确性。掌握游标属性是提升数据处理能力的关键。
|
6天前
|
SQL Oracle 安全
Oracle的PL/SQL循环语句:数据的“旋转木马”与“无限之旅”
【4月更文挑战第19天】Oracle PL/SQL中的循环语句(LOOP、EXIT WHEN、FOR、WHILE)是处理数据的关键工具,用于批量操作、报表生成和复杂业务逻辑。LOOP提供无限循环,可通过EXIT WHEN设定退出条件;FOR循环适用于固定次数迭代,WHILE循环基于条件判断执行。有效使用循环能提高效率,但需注意避免无限循环和优化大数据处理性能。掌握循环语句,将使数据处理更加高效和便捷。
|
6天前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL条件控制:数据的“红绿灯”与“分岔路”
【4月更文挑战第19天】在Oracle PL/SQL中,IF语句与CASE语句扮演着数据流程控制的关键角色。IF语句如红绿灯,依据条件决定程序执行路径;ELSE和ELSIF提供多分支逻辑。CASE语句则是分岔路,按表达式值选择执行路径。这些条件控制语句在数据验证、错误处理和业务逻辑中不可或缺,通过巧妙运用能实现高效程序逻辑,保障数据正确流转,支持企业业务发展。理解并熟练掌握这些语句的使用是成为合格数据管理员的重要一环。
|
6天前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL表达式:数据的魔法公式
【4月更文挑战第19天】探索Oracle PL/SQL表达式,体验数据的魔法公式。表达式结合常量、变量、运算符和函数,用于数据运算与转换。算术运算符处理数值计算,比较运算符执行数据比较,内置函数如TO_CHAR、ROUND和SUBSTR提供多样化操作。条件表达式如CASE和NULLIF实现灵活逻辑判断。广泛应用于SQL查询和PL/SQL程序,助你驾驭数据,揭示其背后的规律与秘密,成为数据魔法师。
|
6天前
|
运维 Oracle 关系型数据库
Oracle日志文件:数据王国的“记事本”
【4月更文挑战第19天】Oracle日志文件是数据库稳定运行的关键,记录数据变更历史,用于恢复和故障处理。它们协调并发操作,确保数据一致性和完整性。日志文件实时写入操作信息并定期刷新到磁盘,便于数据恢复。然而,日志文件需备份和归档以保证安全性,防止数据丢失。日志文件,数据王国的“记事本”,默默守护数据安全。

推荐镜像

更多