【练习】数据移动---parfile导出表中指定行:

要求:

①创建存放数据的文件;

②使用默认的bad文件生成方式;

③使用truncate选项方式。

1.准备条件:

[oracle@host03 ~]$ mkdir datadump
[oracle@host03 ~]$ ls
base.ctl base_data.bad base_data.dat base.log datadump
[oracle@host03 ~]$ cd datadump/
[oracle@host03 datadump]$ pwd
/home/oracle/datadump
[oracle@host03 datadump]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue Dec 13 22:15:05 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 22:16:41 SYS@ORA11GR2>create or replace directory dir_dp as '/home/oracle/datadump'; Directory created. 22:22:30 SYS@ORA11GR2>grant read,write on directory dir_dp to scott; Grant succeeded. 22:22:59 SYS@ORA11GR2>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@host03 datadump]$

2.导出指定表中的指定行:

[oracle@host03 datadump]$ expdp scott/tiger directory=dir_dp dumpfile=emp30.dmp tables=emp query="'where deptno=30'";

Export: Release 11.2.0.4.0 - Production on Tue Dec 13 22:26:51 2016

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/******** directory=dir_dp dumpfile=emp30.dmp tables=emp query='where deptno=30'
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
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
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SCOTT"."EMP" 8.25 KB 6 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
/home/oracle/datadump/emp30.dmp
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at Tue Dec 13 22:27:32 2016 elapsed 0 00:00:33 [oracle@host03 datadump]$ ls
emp30.dmp export.log--->如果没有指定生成log,会默认生成,下次会覆盖

3.parfile导出表中指定行:

[oracle@host03 datadump]$ vi par.txt

userid=scott/tiger
directory=dir_dp
dumpfile=emp30_2.dmp
logfile=emp30_2.log
tables=emp
query='where deptno=30' [oracle@host03 datadump]$ expdp parfile=par.txt Export: Release 11.2.0.4.0 - Production on Tue Dec 13 22:36:52 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/******** parfile=par.txt
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
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
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SCOTT"."EMP" 8.25 KB 6 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
/home/oracle/datadump/emp30_2.dmp
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at Tue Dec 13 22:37:09 2016 elapsed 0 00:00:14

4.查看:

[oracle@host03 datadump]$ ls
emp30_2.dmp emp30_2.log emp30.dmp export.log par.txt
上一篇:微信小程序爬坑日记


下一篇:Redis数据库 01概述| 五大数据类型