温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

expdp和impdp数据泵

发布时间:2020-04-08 22:53:46 来源:网络 阅读:1088 作者:z597011036 栏目:关系型数据库

COMPRESSION={METADATA_ONLY | NONE}       --数据压缩

CONTENT={ALL | DATA_ONLY | METADATA_ONLY}  --指定导出的内容(当设置CONTENT为ALL时,会导出对象元数据及对象数据;当设置为DATA_ONLY时,只导出对象数据;当设置为METADATA_ONLY时,只导出对象元数据。)

DIRECTORY=directory_object            --备份文件存储的路径

DUMPFILE=[directory_object:]file_name [, ...]   --directory_object用于指定目录对象名,file_name用于指定转储文件名。如果不给定directory_object,导出工具会自动使用DIRECTORY选项指定的目录对象。

ESTIMATE={BLOCKS | STATISTICS}    --设置为BLOCKS时,oracle会按照目标对象所占用的数据块个数乘以数据块尺寸估算对象占用的空间;设置为STATISTICS时,会根据最近的统计值给出对象占用空间,这种方法的误差会比较大。无论使用哪种选项值,都会有误差。

ESTIMATE_ONLY={y | n}     --指定是否只估算导出作业所占用的磁盘空间,默认值为N

EXCLUDE=object_type[:name_clause] [, ...]   --用于控制在导出过程中哪些数据库对象不被导出。(object_type用于指定要排除的对象类型,name_clause用于指定要排除的具体对象名称。注意EXCLUDE选项和INCLUDE选项不能同时使用。)

FILESIZE=integer[B | K | M | G]   --限定单个转储文件的最大容量,默认值是0,表示没有文件尺寸的限制。该选项与DUMPFILE选项一同使用。

FULL={y | n}         --是否以全库模式导出数据库。默认为N。

LOGFILE=[directory_object:]file_name     --指定导出过程中日志文件的名称,默认值为export.log。

PARALLEL=integer       --指定执行导出操作的并行度,默认值为1。

SCHEMAS=schema_name [, ...]       --按照SCHEMA模式导出,默认为当前用户。很常用,不做更多的解释。

TABLES=[schema_name.]table_name[:partition_name] [, ...]   --schema_name用于指定用户名,table_name用于指定导出的表名,partition_name用于指定要导出的分区名。

TABLESPACES=tablespace_name [, ...]     --指定需要导出哪个表空间中的表数据。


1.创建备份或者恢复目录

SQL> create directory tong as '/u01';

Directory created.

SQL> grant read,write on directory tong to USERCTLDEV;

Grant succeeded.

SQL> select * from dba_directories where directory_name='TONG';

OWNER       DIRECTORY_NAME      DIRECTORY_PATH

SYS       TONG      /u01

SQL>


2.按用户导出数据

expdp scott/tiger schemas=scott dumpfile=scott.dmp logfile=scott.log directory=tong;


3.按用户并行度导出数据

expdp scott/tiger schemas=scott dumpfile=scott.dmp logfile=scott.log directory=tong parallel=40 


4.按表名导出数据

expdp scott/tiger tables=emp,dept dumpfile=scott.dmp logfile=scott.log directory=tong


5.按表名和带条件导出数据

expdp scott/tiger tables=emp query='where deptno=20' dumpfile=scott.dmp logfile=scott.log directory=tong


6.按表空间导出数据

expdp scott/tiger tablespace=temp,example dumpfile=scott.dmp logfile=scott.log directory=tong


7.导出整个数据库

expdp system/manager directory=tong dumpfile=full.dmp FULL=y


8.将scott用户的数据导入到scott用户下

impdp scott/tiger directory=tong dumpfile=expdp.dmp schemas=scott


9.将scott用户下的dept表导入到system用户下

impdp system/manager directory=tong dumpfile=expdp.dmp tables=scott.dept remap_schema=scott:system


10.导入表空间

impdp system/manager directory=tong dumpfile=tablespace.dmp tablespace=example


11.导入数据库

impdb system/manager directory=dump_dir dumpfile=full.dmp full=y


12.将scoot用户下的abc表空间的数据导入到system用户下的bcd表空间

impdp scott/tiger directory=tong dumpfile=scott.dmp  logfile=scott.log remap_schema=scott:system remap_tablespace=abc:bcd


13.只导出数据,表结构和索引,不导出其它对像

expdp upcenter/zVQpErDi76 tables=FUND_CURR_INFO,FUND_NAV_CALC,FUND_MNY_RETRUN directory=tong dumpfile=upcenter.dump logfile=upcenter.log INCLUDE=TABLE,TABLE_DATA,INDEX compression=ALL


14.如果表空间已存在的表,导入数据有4种情况

TABLE_EXISTS_ACTION=对应以下四个值

SKIP            不管已存在的表,直接跳过

APPEND          保持现有的数据,导入新数据

TRUNCATE         删除原有的数据,导入新数据

REPLACE          删除所有表(drop),并重建(create),再导入新数据


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI