当前位置:网站首页>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
dmpdmporacleTwo 、 The preparation of the instruments
- FileZilla
- SecureCRT
FileZilladmpSecureCRT3、 ... and 、Expdp File export
dmpDIRECTORYSpecify the directory where the dump and log files are located .
DIRECTORY=directory_object
Directory_objectCREATE DIRECTORYOSExpdp 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
CONTENTThis option is used to specify what to export . The default value isALL.
CONTENT={ALL | DATA_ONLY | METADATA_ONLY}
CONTENTALLDATA_ONLYMETADATA_ONLYexpdp zftang/[email protected] directory=dmp dumpfile=test.dmp content=metadata_only
expdp zftang/[email protected] directory=dmp dumpfile=test.dmp content=data_only
DUMPFILEUsed to specify the name of the dump file , The default name isexpdat.dmp.
DUMPFILE=[directory_object:]file_name [,….]
Directory_objectfile_namedirectory_objectDIRECTORYexpdp zftang/[email protected] directory=dmp dumpfile=test1.dmp
DIRECTORYcreate 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.1Four 、 remarks
directory=dir_dpORA-39002: Invalid operation
ORA-39070: Unable to open log file .
ORA-39087: Directory nameDATA_PUMP_DIR; Invalid 2、 In the export process ,DATA DUMPCreated and used a program calledSYS_EXPORT_TABLE_01The object of , This object isDATA DUMPUsed in the export processJOBname , If you do not specify the exportedJOBName, then a defaultJOBname , If... Is specified during exportJOBA 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;
jobexpdp zftang/zftang attach=zftang.my_job15、 ... 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
sysimpdp system/orcl directory=data_pump_dir dumpfile=gwm.dmp remap_tablespace=gmapdata:gcom
7、 ... and 、EXP、IMP And EXPDP、IMPDP The difference between
EXPandIMPIs a client utility , They can be used on the client side , It can also be used on the server .
EXPDPandIMPDPIt is the tool program of the server , They can only be inORACLEServer use , Can't use... On the client side .
IMPOnly applicable toEXPExported files , Do not apply toEXPDPexport file ;IMPDPOnly applicable toEXPDPExported files , Not applicable toEXPexport file .
expdporimpdpOn 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';
NOVALIDATENine 、 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_namealter table table_name disable constraint constraint_nameselect 'alter table '||table_name||' enable constraint '||constraint_name||';' from user_constraints where constraint_type='R'
边栏推荐
- R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
- The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.
- Vulnhub geminiinc
- Deploying WordPress instance tutorial under coreos
- vulnhub之Nagini
- Unity3d learning notes 5 - create sub mesh
- How to get started embedded future development direction of embedded
- Momentum of vulnhub
- Kibana - installation and configuration of kibana
- shardingSphere分库分表<3>
猜你喜欢
随机推荐
vulnhub之Ripper
The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.
《剑指offer 03》数组中重复的数字
Optimize interface performance
Wrong arrangement (lottery, email)
GCC compilation process and dynamic link library and static link library
Cacti监控Redis实现过程
DS90UB949
Visual studio 2022 downloading and configuring opencv4.5.5
Solution to the second weekly test of ACM intensive training of Hunan Institute of technology in 2022
MCDF Experiment 1
Vulnhub geminiinc
剑指offer专项32-96题做题笔记
Yintai department store ignites the city's "night economy"
Cacti monitors redis implementation process
R语言使用gridExtra包的grid.arrange函数将lattice包的多个可视化图像横向组合起来,ncol参数自定义组合图列数、nrow参数自定义组合图行数
Dynamically monitor disk i/o with ZABBIX
Ripper of vulnhub
Kibana - installation and configuration of kibana
MCDF实验1









