当前位置:网站首页>Oracle advanced (I) realize DMP by expdp impdp command
Oracle advanced (I) realize DMP by expdp impdp command
2022-07-03 11:56:00 【InfoQ】
One 、 Preface
dmp
dmp
oracle
Two 、 The preparation of the instruments
- FileZilla
- SecureCRT
FileZilla
dmp
SecureCRT
3、 ... and 、Expdp File export
dmp
DIRECTORY
Specify the directory where the dump and log files are located .
DIRECTORY=directory_object
Directory_object
CREATE DIRECTORY
OS
Expdp scott/tiger DIRECTORY= DMP DUMPFILE=a.dump
create or replace directory dmp as 'd:/dmp'
expdp zftang/zftang(@zftang) directory=dmp dumpfile=test.dmp content=metadata_only
CONTENT
This option is used to specify what to export . The default value isALL
.
CONTENT={ALL | DATA_ONLY | METADATA_ONLY}
CONTENT
ALL
DATA_ONLY
METADATA_ONLY
expdp zftang/[email protected] directory=dmp dumpfile=test.dmp content=metadata_only
expdp zftang/[email protected] directory=dmp dumpfile=test.dmp content=data_only
DUMPFILE
Used to specify the name of the dump file , The default name isexpdat.dmp
.
DUMPFILE=[directory_object:]file_name [,….]
Directory_object
file_name
directory_object
DIRECTORY
expdp zftang/[email protected] directory=dmp dumpfile=test1.dmp
DIRECTORY
create directory dir_dp as 'D:/oracle/dir_dp';
Grant read,write on directory dir_dp to zftang;
SELECT privilege, directory_name, DIRECTORY_PATH FROM user_tab_privs t, all_directories d WHERE t.table_name(+) = d.directory_name ORDER BY 2, 1;
expdp zftang/[email protected] schemas=zftang directory=dir_dp dumpfile =expdp_test1.dmp logfile=expdp_test1.log;
Oracle Database 10g Enterprise Edition Release 10.2.0.1
Four 、 remarks
directory=dir_dp
ORA-39002
: Invalid operation
ORA-39070
: Unable to open log file .
ORA-39087
: Directory nameDATA_PUMP_DIR
; Invalid 2、 In the export process ,DATA DUMP
Created and used a program calledSYS_EXPORT_TABLE_01
The object of , This object isDATA DUMP
Used in the export processJOB
name , If you do not specify the exportedJOB
Name, then a defaultJOB
name , If... Is specified during exportJOB
A name is a given name .
expdp zftang/[email protected] schemas=zftang directory=dir_dp dumpfile =expdp_test1.dmp logfile=expdp_test1.log,job_name=my_job1;
job
expdp zftang/zftang attach=zftang.my_job1
5、 ... and 、 Various modes of data pump export
5.1 Export in table mode :
expdp zftang/[email protected] tables=zftang.b$i_exch_info,zftang.b$i_manhole_info dumpfile
=expdp_test2.dmp logfile=expdp_test2.log directory=dir_dp
job_name=my_job
5.2 Export by query condition
expdp zftang/[email protected] tables=zftang.b$i_exch_info dumpfile =expdp_test3.dmp logfile=expdp_test3.log directory=dir_dp job_name=my_job query='"where rownum<11"'
5.3 Export by table space
Expdp zftang/[email protected] dumpfile=expdp_tablespace.dmp tablespaces=GCOMM.DBF logfile=expdp_tablespace.log directory=dir_dp job_name=my_job
5.4 Export scheme
Expdp zftang/zftang DIRECTORY=dir_dp DUMPFILE=schema.dmp SCHEMAS=zftang,gwm
5.5 Export the entire database
expdp zftang/[email protected] dumpfile =full.dmp full=y logfile=full.log directory=dir_dp job_name=my_job
6、 ... and 、Impdp File import
6.1 Import by table
impdp gwm/[email protected] dumpfile =p_street_area.dmp
logfile=imp_p_street_area.log directory=dir_dp tables=p_street_area
job_name=my_job
6.2 Import by user ( You can import user information directly into , That is, if the user information does not exist, it can also be imported directly )
impdp gwm/[email protected] schemas=gwm dumpfile =expdp_test.dmp logfile=expdp_test.log directory=dir_dp job_name=my_job
6.3 Not through expdp To generate dmp File and direct import method
-- Import tables from the source database to the target database p_street_area
impdp gwm/gwm directory=dir_dp NETWORK_LINK=igisdb tables=p_street_area logfile=p_street_area.log job_name=my_job
igisdb Is the link name between the destination database and the source data ,dir_dp Is the directory on the destination database
6.4 Change the table space
remap_tablespace
-- export gwm All the data under the user
expdp system/orcl directory=data_pump_dir dumpfile=gwm.dmp SCHEMAS=gwm
sys
impdp system/orcl directory=data_pump_dir dumpfile=gwm.dmp remap_tablespace=gmapdata:gcom
7、 ... and 、EXP、IMP And EXPDP、IMPDP The difference between
EXP
andIMP
Is a client utility , They can be used on the client side , It can also be used on the server .
EXPDP
andIMPDP
It is the tool program of the server , They can only be inORACLE
Server use , Can't use... On the client side .
IMP
Only applicable toEXP
Exported files , Do not apply toEXPDP
export file ;IMPDP
Only applicable toEXPDP
Exported files , Not applicable toEXP
export file .
expdp
orimpdp
On command , Don't indicate the user name for the moment / password @ Instance name as identity , And then type... According to the prompt , Such as :
expdp schemas=scott dumpfile=expdp.dmp DIRECTORY=dpdata1;
8、 ... and 、 Export and import may encounter obstacles
8.1 Chinese character set conversion
- KUP-11007:
conversion error loading table "TEST"."T_PSR" ORA-12899:
Column REASON_CODE It's worth too much ( actual value : 21, Maximum : 20)
- KUP-11009:
data for row: REASON_CODE : 0X'BABDBFD5C6F7C8DDC1BFCFDED6C6'
8.2 Primary foreign key Association
- ORA-31693:
Table data object "TEST"."T_ITE" failed to load/unload and is being skipped due to error:
- ORA-29913:
error in executing ODCIEXTTABLEFETCH callout
- ORA-02291:
integrity constraint (TEST.FK_ITE_REF_PSR) violated parent key not found
- Before importing , The implementation is as follows SQL Find the foreign key association that needs to be forbidden
select 'ALTER TABLE '||TABLE_NAME||' DISABLE CONSTRAINT '||constraint_name||';'from user_constraints WHERE
CONSTRAINT_TYPE='R';
- perform (a) Result SQL.
- After import , The implementation is as follows SQL Find the foreign key association that needs to be restored
select 'ALTER TABLE '||TABLE_NAME||' ENABLE NOVALIDATE CONSTRAINT '||constraint_name||';' from user_constraints WHERE
CONSTRAINT_TYPE='R';
NOVALIDATE
Nine 、 summary
- Use 10g The above version provides expdp/impdp Data pump import and export tool , More than ever exp/imp Tools , Whether in terms of the optional parameters , Or speed and compression ratio , There have been no small improvements , Provide us with more convenient and fast data import and export methods .
- Import and export may encounter the most problems , Character set conversion is one of them , It is necessary to clarify the dependence of imported and exported data on character sets , To ensure the correct import and export of data .
- For data associated with primary and foreign keys , If you choose data_only Export data only , Then you can disable constraints before importing , In this way, the import process will not be affected by the primary foreign key Association , Constraints can be restored after import , Ensure that the constraints are correct .
Ten 、 Delete foreign key constraint
ALTER TABLE test_sub DROP CONSTRAINT main_id_cons;
constraint_type='R'
alter table table_name enable constraint constraint_name
alter table table_name disable constraint constraint_name
select 'alter table '||table_name||' enable constraint '||constraint_name||';' from user_constraints where constraint_type='R'
边栏推荐
- Groovy测试类 和 Junit测试
- Uniapp implementation Click to load more
- . \vmware-vdiskmanager. exe -k “c:\\xxxxx.vmdk”
- Hongmeng third training (project training)
- R语言使用aggregate函数计算dataframe数据分组聚合的均值(sum)、不设置na.rm计算的结果、如果分组中包含缺失值NA则计算结果也为NA
- PHP基础
- vulnhub之Nagini
- R语言使用原生包(基础导入包、graphics)中的hist函数可视化直方图(histogram plot)
- Kubernetes three dozen probes and probe mode
- 并发编程-单例
猜你喜欢
Web security summary
cgroup简介
Kubernetes 三打探针及探针方式
ArcGIS application (XXI) ArcMap method of deleting layer specified features
银泰百货点燃城市“夜经济”
Vulnhub's Tomato (tomato)
Qt OpenGL 纹理贴图
【mysql官方文档】死锁
win10 上PHP artisan storage:link 出现 symlink (): Protocol error的解决办法
The world's most popular font editor FontCreator tool
随机推荐
【mysql官方文档】死锁
Nestjs configuration service, configuring cookies and sessions
简单工厂和工厂方法模式
Nestjs配置服务,配置Cookie和Session
MySQL uses the method of updating linked tables with update
Kibana~Kibana的安装和配置
Understand go language context in one article
uniapp实现点击加载更多
外插散点数据
Dynamically monitor disk i/o with ZABBIX
vulnhub之tomato(西红柿)
Unity3D学习笔记5——创建子Mesh
GCC compilation process and dynamic link library and static link library
Differences between MySQL Union and union all
MCDF Experiment 1
Cacti monitors redis implementation process
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
Momentum of vulnhub
How should intermediate software designers prepare for the soft test
[learning notes] DP status and transfer