当前位置:网站首页>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'
边栏推荐
- C language utf8toutf16 (UTF-8 characters are converted to hexadecimal encoding)
- 错排问题 (抽奖,发邮件)
- 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
- Modular programming of single chip microcomputer
- STL tutorial 8-map
- Qt OpenGL 纹理贴图
- 剑指offer专项32-96题做题笔记
- Go language to realize static server
- The R language uses the hist function in the native package (basic import package, graphics) to visualize the histogram plot
- Master and backup role election strategy in kept
猜你喜欢
随机推荐
MCDF实验1
uniapp实现点击加载更多
Go语言实现静态服务器
在CoreOS下部署WordPress实例教程
R语言使用原生包(基础导入包、graphics)中的hist函数可视化直方图(histogram plot)
836. 合并集合(DAY 63)并查集
Interview experience in summer camp of Central South University in 2022
Visual studio 2022 downloading and configuring opencv4.5.5
Vulnhub geminiinc V2
R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据、在折线移动方向添加数据点
vulnhub之GeminiInc
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
Based on MCU, how to realize OTA differential upgrade with zero code and no development?
【学习笔记】dp 状态与转移
Kibana~Kibana的安装和配置
Qt OpenGL 旋转、平移、缩放
Concurrent programming - singleton
cgroup简介
vulnhub之raven2
DNS多点部署IP Anycast+BGP实战分析