数据泵的导出:
|
1,部分的exp中的参数仍然可用,有的不能使用,如index。
2,directory:供转储文件和日志文件使用的目录对象。
3,job_name:指定的任务的名称。
4,content:指定要导出的数据, 其中有效关键字值为: (ALL), DATA_ONLY 和 METADATA_ONLY,当设置content为ALL 时,将导出对象定义及其所有数据;
DATA_ONLY时,只导出对象数据;为METADATA_ONLY时,只导出对象定义 。
5,reuse_dumpfiles:如果导出文件已经存在,是否覆盖。
6,compression:压缩导出文件。
7,estimate:指定估算被导出表所占用磁盘空间分方法.默认值是BLOCKS
8, estimate_only:是否只估算导出占用的磁盘空间,而不进行真正的导出,默认是N。
9,exclude:用于指定执行操作时要排除对象类型或相关对象,用法:EXCLUDE=object_type[:name_clause] [,….]
10,include:用于指定执行操作时要包含的对象类型或相关对象,用法:INCLUDE=object_type[:name_clause] [,….]
11,query:导出符合条件的行。
12,attch:连接到现有的作业,可以用在中断导出任务后重新启动导出任务。
----------------------------------------------------------------
[oracle@localhost oracle]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 21 20:50:29 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create directory test_impdp_expdp as '/u01/app/oracle/test_impdp_expdp';
Directory created.--创建目录
SQL> grant write,read on directory test_impdp_expdp to hr;
Grant succeeded.--给用户赋予权限
SQL> grant write,read on directory test_impdp_expdp to test1;
Grant succeeded.--给用户赋予权限
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Productio
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost oracle]$ cd test_impdp_expdp/
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP dumpfile
--默认是多出用户的所有的对象
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:14:04 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "HR"."SYS_EXPORT_SCHEMA_01": hr/********@jiagulun directory=TEST_IMPDP_EXPDP dumpfi
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 768 KB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/CLUSTER/CLUSTER
Processing object type SCHEMA_EXPORT/CLUSTER/INDEX
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/VIEW/VIEW
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/TRIGGER
Processing object type SCHEMA_EXPORT/EVENT/TRIGGER
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/JOB
. . exported "HR"."ADDRESS" 5.476 KB 2 rows
. . exported "HR"."COUNTRIES" 6.367 KB 25 rows
. . exported "HR"."DEPARTMENTS" 7.007 KB 27 rows
. . exported "HR"."DEPT" 5.492 KB 3 rows
. . exported "HR"."DROPPED_OBJ" 6.367 KB 21 rows
. . exported "HR"."EMPLOYEES" 16.81 KB 107 rows
. . exported "HR"."JOBS" 6.992 KB 19 rows
. . exported "HR"."JOB_HISTORY" 7.054 KB 10 rows
. . exported "HR"."LOCATIONS" 8.273 KB 23 rows
. . exported "HR"."REGIONS" 5.476 KB 4 rows
. . exported "HR"."STUDENT" 5.937 KB 3 rows
. . exported "HR"."TEST_JOB" 24.74 KB 1684 rows
Master table "HR"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.SYS_EXPORT_SCHEMA_01 is:
/u01/app/oracle/test_impdp_expdp/test_exp_01.dmp
Job "HR"."SYS_EXPORT_SCHEMA_01" successfully completed at 22:16:07
[oracle@localhost test_impdp_expdp]$ ls
export.log test_exp_01.dmp
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP TABLES=Sexp_02.dmp EXCLUDE=INDEX:"=\'INDEX_ADDRESS_NAME\'"
LRM-00116: syntax error at 'INDEX:' following '='
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP TABLES=Sexp_02.dmp EXCLUDE=INDEX:"IN\'INDEX_ADDRESS_NAME\'"
.--通过上面的导出你会发现需要对'进行转义,而且是IN关键字
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:25:09 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "HR"."SYS_EXPORT_TABLE_01": hr/********@jiagulun directory=TEST_IMPDP_EXPDP TABLES=_exp_02.dmp EXCLUDE=INDEX:IN\'INDEX_ADDRESS_NAME\'
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 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/STATISTICS/TABLE_STATISTICS
. . exported "HR"."ADDRESS" 5.476 KB 2 rows
. . exported "HR"."STUDENT" 5.937 KB 3 rows
Master table "HR"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.SYS_EXPORT_TABLE_01 is:
/u01/app/oracle/test_impdp_expdp/test_exp_02.dmp
Job "HR"."SYS_EXPORT_TABLE_01" successfully completed at 22:25:20
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student,address encryption=dmpfiles=test_exp_encrytion_reuse_01.dmp
LRM-00101: unknown parameter name 'dumpfiles'
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student,address encryption=dmpfile=test_exp_encrytion_reuse_01.dmp
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:32:31 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-39145: directory object parameter must be specified and non-null
--对于上面的错误是因为没有打开或者不存在encryption wallet所以需要进行下面操作:
oracle Wallet的使用(即内部加密技术TDE(Transparent Data Encryption ))
1. TDE是Oracle10gR2中推出的一个新功能,使用时要保证Oracle版本是在10gR2或者以上
--查看oracle版本:
select * from v$version;
2、创建一个新目录,并指定为Wallet目录
D:\oracle\product\10.2.0\admin\ora10\ora_wallet
3. 设置wallet目录,在参数文件sqlnet.ora中(window+f,在你安装盘区查找sqlnet.ora),按照下面的格式加入信息:
ENCRYPTION_WALLET_LOCATION=(SOURCE=(METHOD=FILE)
(METHOD_DATA=(DIRECTORY=D:\oracle\product\10.2.0\admin\ora10\ora_wallet)))
4. 创建master key文件,指定wallet密码,使用SYS用户登入系统,建立加密文件
SQL> alter system set encryption key identified by "wallet";
System altered
-- 密码"wallet"不加引号时,后面使用时也不需要用引号
此时在设置的目录下,多出一个Personal Information Exchange类型的文件,相当于我们生成的master key文件。D:\oracle\product\10.2.0\admin\ora10\ora_wallet\ewallet.p12
5、启动、关闭Wallet
SQL> ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "wallet";
ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "wallet"
ORA-28354: wallet 已经打开
SQL> ALTER SYSTEM SET ENCRYPTION WALLET CLOSE; --关闭
System altered
SQL> ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "wallet"; --打开
System altered
到此,已经成功配置了Wallet,创建了master key。
--通过上面的创建并且开启encryption wallet后才可以进行如下
[oracle@localhost wallet]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPDP_EXPDP dumpfile=test_exp_encryption_1.dmp encryption=data_only
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:57:01 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "HR"."SYS_EXPORT_TABLE_01": hr/********@jiagulun tables=student directory=TEST_IMPDP_EXPDP dumpfile=test_exp_encryption_1.dmp encryption=data_only
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/STATISTICS/TABLE_STATISTICS
. . exported "HR"."STUDENT" 5.945 KB 3 rows
Master table "HR"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.SYS_EXPORT_TABLE_01 is:
/u01/app/oracle/test_impdp_expdp/test_exp_encryption_1.dmp
Job "HR"."SYS_EXPORT_TABLE_01" successfully completed at 23:57:08
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student compression=data_onl reuse_dumpfiles=y dumpfile=test_exp_01.dmp--reuse_dumpfiles表示可以覆盖原文件
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:41:57 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "HR"."SYS_EXPORT_TABLE_01": hr/********@jiagulun tables=student compression=data_on reuse_dumpfiles=y dumpfile=test_exp_01.dmp
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/STATISTICS/TABLE_STATISTICS
. . exported "HR"."STUDENT" 4.914 KB 3 rows
Master table "HR"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.SYS_EXPORT_TABLE_01 is:
/u01/app/oracle/test_impdp_expdp/test_exp_01.dmp
Job "HR"."SYS_EXPORT_TABLE_01" successfully completed at 22:42:02
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPDP_EXPDP
EXCLUDE=CONSTRAINT:IN\'PK_PRIMARY\'" dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname
--需要转义和大写
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:56:23 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "HR"."TEST_EXP_JOBNAME": hr/********@jiagulun tables=student directory=TEST_IMPDP_EK_PRIMARY\' dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname
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/STATISTICS/TABLE_STATISTICS
. . exported "HR"."STUDENT" 5.937 KB 3 rows
Master table "HR"."TEST_EXP_JOBNAME" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.TEST_EXP_JOBNAME is:
/u01/app/oracle/test_impdp_expdp/test_exp_jobname.dmp
Job "HR"."TEST_EXP_JOBNAME" successfully completed at 22:56:28
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPIN\'PK_PRIMARY\'" dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 22:57:02 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31641: unable to create dump file "/u01/app/oracle/test_impdp_expdp/test_exp_jobname.dmp"
ORA-27038: created file already exists
Additional information: 1
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPIN\'PK_PRIMARY\'" dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname REUSE_DUMPFILES=Y
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:16:05 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "HR"."TEST_EXP_JOBNAME": hr/********@jiagulun tables=student directory=TEST_IMPDP_EK_PRIMARY\' dumpfile=test_exp_jobname.dmp job_name=test_exp_jobname REUSE_DUMPFILES=Y
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/STATISTICS/TABLE_STATISTICS
. . exported "HR"."STUDENT" 5.937 KB 3 rows
Master table "HR"."TEST_EXP_JOBNAME" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.TEST_EXP_JOBNAME is:
/u01/app/oracle/test_impdp_expdp/test_exp_jobname.dmp
Job "HR"."TEST_EXP_JOBNAME" successfully completed at 23:16:19
[oracle@localhost test_impdp_expdp]$ exp hr/hr@jiagulun TABLES=STUDENT DIRECTORY=test_impdp_etion.dmp
LRM-00101: unknown parameter name 'DIRECTORY'
EXP-00019: failed to process parameters, type 'EXP HELP=Y' for help
EXP-00000: Export terminated unsuccessfully
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id <2" dumpfile=test_exp_query.dmp
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:17:57 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id <2" dumpfile=test_exp_query.dmp reuse_dumpfile=y
LRM-00101: unknown parameter name 'reuse_dumpfile'
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id <2" dumpfile=test_exp_query.dmp reuse_dumpfiles=y
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:18:28 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id <2" dumpfile=test_exp_query_1.dmp
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:18:56 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP query=s=test_exp_query_1.dmp
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:19:11 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP query=s=test_exp_query_1.dmp
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:19:37 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP query=se=test_exp_query_1.dmp
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:21:12 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP id \<2" dumpfile=test_exp_query_1.dmp
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:21:41 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMP dumpfile=test_exp_query_1.dmp
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:26:04 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPery_1.dmp query=STUDENT:"WHERE ID < 2"
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:28:16 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPery_1.dmp query=STUDENT:"WHERE ID \< 2"
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:28:23 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39035: Data filter SUBQUERY has already been specified.
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun tables=student directory=TEST_IMPery_1.dmp query=STUDENT:\"WHERE ID \< 2\"
--通过上面的错误可以知道符号需要被转义和query的使用方式
Export: Release 11.2.0.1.0 - Production on Wed Jan 21 23:28:30 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "HR"."SYS_EXPORT_TABLE_01": hr/********@jiagulun tables=student directory=TEST_IMPDry_1.dmp query=STUDENT:"WHERE ID < 2"
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/STATISTICS/TABLE_STATISTICS
. . exported "HR"."STUDENT" 5.906 KB 1 rows
Master table "HR"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.SYS_EXPORT_TABLE_01 is:
/u01/app/oracle/test_impdp_expdp/test_exp_query_1.dmp
Job "HR"."SYS_EXPORT_TABLE_01" successfully completed at 23:28:40
WRL_TYPE
--------------------
WRL_PARAMETER
--------------------------------------------------------------------------------
STATUS
------------------
file
/u01/app/oracle/admin/jiagulun/wallet
CLOSED
|
数据泵的导入:
|
1,content:指定要加载的数据, 其中有效关键字值为: (ALL), DATA_ONLY 和 METADATA_ONLY,当设置content为ALL 时,将加载对象定义及其所有数据;
DATA_ONLY时,只加载对象数据;为METADATA_ONLY时,只加载对象定义 。
2,estimate:估算所占用磁盘空间分方法.默认值是BLOCKS
3,remap_schema:用于将对象从一个用户下导入到另一个用户下。
4,remap_tablespace:用于将对象从一个表空间下导入到另一个表空间下。
5,remap_datafile:用于在不同文件系统的平台间,切换数据文件路径。
remap_achema:导入
[oracle@localhost test_impdp_expdp]$ expdp hr/hr@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_01.dmp schemas= hr
Export: Release 11.2.0.1.0 - Production on Thu Jan 22 00:59:42 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "HR"."SYS_EXPORT_SCHEMA_01": hr/********@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_01.dmp schemas=
Estimate in progress using BLOCKS method...
[oracle@localhost test_impdp_expdp]$ impdp test1/test1@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_01.dmp REMAP_SCHEMA=HR:TEST1
Import: Release 11.2.0.1.0 - Production on Thu Jan 22 01:10:11 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "TEST1"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "TEST1"."SYS_IMPORT_FULL_01": test1/********@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_01.dmp REMAP_SCHEMA=HR:TEST1
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
remap_tablespace导入
通过remap_tablespace来变换表所属表空间:
SQL> select segment_name,segment_type,tablespace_name from user_extents ;
SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME
-------------------------------------------------------------------------------- ------------------ ------------------------------
REGIONS TABLE EXAMPLE
LOCATIONS TABLE EXAMPLE
DEPARTMENTS TABLE EXAMPLE
JOBS TABLE EXAMPLE
EMPLOYEES TABLE EXAMPLE
JOB_HISTORY TABLE EXAMPLE
DEPT TABLE USERS
DROPPED_OBJ TABLE USERS
TEST_JOB TABLE USERS
STUDENT TABLE TEST_TRAN_TS
ADDRESS TABLE TEST_TRAN_TS
[oracle@localhost test_impdp_expdp]$ expdp \'sys/oracle@jiagulun as sysdba\' directory=test_impdp_expdp dumpfile=exp_04.dmp tablespaces=users--导出表空间
Export: Release 11.2.0.1.0 - Production on Thu Jan 22 01:20:04 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLESPACE_01": "sys/********@jiagulun AS SYSDBA" directory=test_impdp_expdp dumpfile=exp_02.dmp tablespaces=users
Estimate in progress using BLOCKS method...
SQL> drop table student purge;
Table dropped.--之所以要先删除再导入表是因为在一个数据库中一个用户中的对象是唯一的,所以先删除再导入
SQL> drop table address purge;
Table dropped.
SQL> commit;
Commit complete.
[oracle@localhost test_impdp_expdp]$ impdp \'sys/oracle@jiagulun as sysdba\' directory=test_impdp_expdp dumpfile=exp_04.dmp REMAP_TABLESPACE=test_tran_ts:users--导入表空间到test_tran_ts
Import: Release 11.2.0.1.0 - Production on Thu Jan 22 01:28:45 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_FULL_01": "sys/********@jiagulun AS SYSDBA" directory=test_impdp_expdp dumpfile=exp_02.dmp REMAP_TABLESPACE=users:test_tran_ts
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "HR"."ADDRESS" 5.476 KB 2 rows
. . imported "HR"."STUDENT" 5.937 KB 3 rows
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
SQL> select segment_name,segment_type,tablespace_name from user_extents ;
SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME
-------------------------------------------------------------------------------- ------------------ ------------------------------
REGIONS TABLE EXAMPLE
LOCATIONS TABLE EXAMPLE
DEPARTMENTS TABLE EXAMPLE
JOBS TABLE EXAMPLE
EMPLOYEES TABLE EXAMPLE
JOB_HISTORY TABLE EXAMPLE
STUDENT TABLE USERS
ADDRESS TABLE USERS
为了把用户按表空间归类,需要把用户所有的当前数据转移到另一个表空间里,那么可以使用impdp的remap_tablespace参数。下面就这一内容进行实验。
SQL> select du.username,du.default_tablespace,du.temporary_tablespace from dba_users du where du.username='HR';
USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE
------------------------------ ------------------------------ ------------------------------
HR USERS TEMP2
SQL> select segment_name,segment_type,tablespace_name from user_extents where rownum < 10;
SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME
-------------------------------------------------------------------------------- ------------------ ------------------------------
REGIONS TABLE EXAMPLE
LOCATIONS TABLE EXAMPLE
DEPARTMENTS TABLE EXAMPLE
JOBS TABLE EXAMPLE
EMPLOYEES TABLE EXAMPLE
JOB_HISTORY TABLE EXAMPLE
STUDENT TABLE USERS
ADDRESS TABLE USERS
DEPT TABLE USERS
9 rows selected
SQL>
[oracle@localhost test_impdp_expdp]$ expdp system/oracle@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_03.dmp schemas=hr
Export: Release 11.2.0.1.0 - Production on Thu Jan 22 02:22:28 2015
--导出hr用户对象信息,使用system导出的更加的全
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
[oracle@localhost test_impdp_expdp]$ impdp system/oracle@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_03.dmp remap_tablespace=users:test_tran_ts--导入hr用户中是users表空间的数据到test_tran_ts表空间中
Import: Release 11.2.0.1.0 - Production on Thu Jan 22 05:33:10 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
SQL> select segment_name,segment_type,tablespace_name from user_extents where rownum < 10;
SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME
-------------------------------------------------------------------------------- ------------------ ------------------------------
REGIONS TABLE EXAMPLE
LOCATIONS TABLE EXAMPLE
DEPARTMENTS TABLE EXAMPLE
JOBS TABLE EXAMPLE
EMPLOYEES TABLE EXAMPLE
JOB_HISTORY TABLE EXAMPLE
STUDENT TABLE USERS
ADDRESS TABLE USERS
DEPT TABLE USERS
9 rows selected
--会发现表所在表空间并没有变化,是因为原来的已经存在不会覆盖
SQL> select du.username,du.default_tablespace,du.temporary_tablespace from dba_users du where du.username='HR';
USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE
------------------------------ ------------------------------ ------------------------------
HR USERS TEMP2
注意:经过导入后,用户test_user的缺省表空间被改成了remap_tablespace的目的表空间, 但是这里没有变化也是因为已经存在了。
把表和用户删除了,就会发现他们的表空间变额
SQL> drop table student;
Table dropped.
SQL> drop table address;
Table dropped.
SQL> commit;
Commit complete.
SQL> purge recyclebin
2 ;
[oracle@localhost test_impdp_expdp]$ impdp system/oracle@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_03.dmp remap_tablespace=users:test_tran_ts
Import: Release 11.2.0.1.0 - Production on Thu Jan 22 05:48:49 2015
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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/********@jiagulun directory=TEST_IMPDP_EXPDP dumpfile=exp_03.dmp remap_tablespace=users:test_tran_ts
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"HR" already exists--由于存在所以直接跳过
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
ORA-31684: Object type SEQUENCE:"HR"."EMPLOYEES_SEQ" already exists
ORA-31684: Object type SEQUENCE:"HR"."DEPARTMENTS_SEQ" already exists
ORA-31684: Object type SEQUENCE:"HR"."LOCATIONS_SEQ" already exists
Processing object type SCHEMA_EXPORT/CLUSTER/CLUSTER
ORA-31684: Object type CLUSTER:"HR"."CLUSTER1" already exists
Processing object type SCHEMA_EXPORT/CLUSTER/INDEX
ORA-39111: Dependent object type INDEX:"HR"."CLUSTER_INDEX" skipped, base object type CLUSTER:"HR"."CLUSTER1" already exists
Processing object type SCHEMA_EXPORT/TABLE/TABLE
ORA-39151: Table "HR"."COUNTRIES" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
ORA-39151: Table "HR"."REGIONS" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
ORA-39151: Table "HR"."LOCATIONS" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
ORA-39151: Table "HR"."DEPARTMENTS" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
ORA-39151: Table "HR"."JOBS" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
ORA-39151: Table "HR"."EMPLOYEES" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
ORA-39151: Table "HR"."JOB_HISTORY" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
ORA-39151: Table "HR"."DEPT" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
ORA-39151: Table "HR"."DROPPED_OBJ" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
ORA-39151: Table "HR"."TEST_JOB" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "HR"."ADDRESS" 5.476 KB 2 rows
. . imported "HR"."STUDENT" 5.937 KB 3 rows
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
.. . . . . . . . ..
SQL> select segment_name,segment_type,tablespace_name from user_extents ;
SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME
-------------------------------------------------------------------------------- ------------------ ------------------------------
STUDENT TABLE TEST_TRAN_TS
ADDRESS TABLE TEST_TRAN_TS
CLUSTER1 CLUSTER USERS
--你会发现他们的表空间变化了。
|
注意:一个用户对象是唯一的,即使在不同的表空间中也是一样的
SQL> create table test1(id number);--默认是使用sys
Table created.
SQL> create table test1(id number) tablespace test_tran_ts;--使用test_tran_ts
create table test1(id number) tablespace test_tran_ts
*
ERROR at line 1:
ORA-00955: name is already used by an existing object
SQL> |
|