日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle分区表导入数据,Oracle 分区表数据的导入与导出(2)

發布時間:2023/12/20 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle分区表导入数据,Oracle 分区表数据的导入与导出(2) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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_NAMEDIRECTORY_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 KB2875 rows

. . exported "SCOTT"."TB_PT":"SAL_11"12.54 KB298 rows

. . exported "SCOTT"."TB_PT":"SAL_12"14.22 KB366 rows

. . exported "SCOTT"."TB_PT":"SAL_13"14.18 KB365 rows

. . exported "SCOTT"."TB_PT":"SAL_14"14.18 KB365 rows

. . exported "SCOTT"."TB_PT":"SAL_15"14.19 KB365 rows

. . exported "SCOTT"."TB_PT":"SAL_16"14.23 KB366 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 KB2875 rows

. . exported "SCOTT"."TB_PT":"SAL_16"14.23 KB366 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_NAMESTATUSPAR

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

TB_PT_IND1UNUSABLE NO

TB_PT_LOCAL_IDXN/AYES

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

INDEX_NAMEPARTITION_NAMESTATUS

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

TB_PT_LOCAL_IDXLOCAL1USABLE

TB_PT_LOCAL_IDXLOCAL2USABLE

TB_PT_LOCAL_IDXLOCAL3USABLE

TB_PT_LOCAL_IDXLOCAL4USABLE

TB_PT_LOCAL_IDXLOCAL5USABLE

TB_PT_LOCAL_IDXLOCAL6USABLE

TB_PT_LOCAL_IDXLOCAL7USABLE

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 KB2875 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_NAMESTATUSPAR

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

TB_PT_IND1VALIDNO

TB_PT_LOCAL_IDXN/AYES

從上面的導入情況可以看出,盡管執行了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 KB2875 rows

. . imported "SCOTT"."TB_PT":"SAL_11"12.54 KB298 rows

. . imported "SCOTT"."TB_PT":"SAL_12"14.22 KB366 rows

. . imported "SCOTT"."TB_PT":"SAL_13"14.18 KB365 rows

. . imported "SCOTT"."TB_PT":"SAL_14"14.18 KB365 rows

. . imported "SCOTT"."TB_PT":"SAL_15"14.19 KB365 rows

. . imported "SCOTT"."TB_PT":"SAL_16"14.23 KB366 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

NAMETYPEVALUE

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

skip_unusable_indexesbooleanTRUE

該參數允許在導入分區數據時延遲對索引的處理,即先將數據導入,導入后再來重建索引分區。

在命令行導入中未指定導入參數skip_unusable_indexes時,則對于索引相關的問題,根據數據庫初始化參數的值來確定。

在命令行導入中如果指定了參數skip_unusable_indexes時,則該參數的值優先于數據庫初始化參數的設定值。

skip_unusable_indexes=y對unique index不起作用,因為此時的unique index扮演者constraint的作用,所以在insert數據時index必須被

更新。

對于單個分區導入時PK,unique index的處理,必須先重建索引然后進行導入。

使用impdp數據泵實現導入并使用參數table_exists_action=replace可以解決上述問題,即ORA-01502錯誤。

總結

以上是生活随笔為你收集整理的oracle分区表导入数据,Oracle 分区表数据的导入与导出(2)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。