当前位置:网站首页>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'
边栏推荐
- Vulnhub pyexp
- vulnhub之GeminiInc
- R language uses the aggregate function to calculate the mean value (sum) of dataframe data grouping aggregation without setting na The result of RM calculation. If the group contains the missing value
- Web安全总结
- 小鹏 P7 撞护栏安全气囊未弹出,官方回应称撞击力度未达到弹出要求
- VS2015的下载地址和安装教程
- typeScript
- Optimize interface performance
- Master and backup role election strategy in kept
- vulnhub之pyexp
猜你喜欢
vulnhub之presidential
cgroup简介
Kibana~Kibana的安装和配置
Colleagues wrote a responsibility chain model, with countless bugs
解决msvcp120d.dll和msvcr120d.dll缺失
Quantitative calculation research
vulnhub之momentum
MCDF实验1
How should intermediate software designers prepare for the soft test
Software testing weekly (issue 78): the more confident you are about the future, the more patient you are about the present.
随机推荐
Web security summary
uniapp scroll view 解决高度自适应、弹框滚动穿透等问题。
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
Keepalived中Master和Backup角色选举策略
Optimize interface performance
Excel quick cross table copy and paste
Introduction to the implementation principle of rxjs observable filter operator
PHP基础
MySQL uses the method of updating linked tables with update
Yintai department store ignites the city's "night economy"
vulnhub之raven2
Kibana - installation and configuration of kibana
Qt OpenGL相机的使用
简单工厂和工厂方法模式
Colleagues wrote a responsibility chain model, with countless bugs
836. 合并集合(DAY 63)并查集
php 获取文件夹下面的文件列表和文件夹列表
mysql使用update联表更新的方法
STL教程8-map
Based on MCU, how to realize OTA differential upgrade with zero code and no development?