现在的位置: 首页 > 综合 > 正文

使用EXPDP/IMPDP导入导出表中数据/元数据测试

2013年03月27日 ⁄ 综合 ⁄ 共 1810字 ⁄ 字号 评论关闭

首先创建导出目录:  --更详细命令及参数,见:http://blog.csdn.net/haibusuanyun/article/details/12584727
BYS@ bys3>create directory dir_dp as '/home/oracle/';
Directory created.
BYS@ bys3>grant read,write on directory dir_dp to public;
Grant succeeded.
col privilege for a15
col directory_name for a15
col directory_path for a30
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;    --可以使用此语句验证配置。
#######################################################

导出用户某个表测试:

只BYS用户下表定义不导出数据:
expdp bys/bys tables=bys.test1 directory=dir_dp dumpfile=bys1.dmp logfile=bys1.log content=metadata_only
只BYS用户下数据不导出表定义:
expdp bys/bys tables=bys.test1  directory=dir_dp dumpfile=bys2.dmp logfile=bys2.log content=data_only
导出BYS用户下所有对象--content不写,默认是ALL.
expdp bys/bys tables=bys.test1  directory=dir_dp file=bys3.dmp logfile=bys3.log
####################################################

导出整个用户下对象测试:

导出整个用户下对象的元数据:
expdp bys/bys schemas=bys  directory=dir_dp file=bys4.dmp logfile=bys4.log content=metadata_only
导出整个用户下的对象
expdp bys/bys schemas=bys  directory=dir_dp file=bys5.dmp logfile=bys5.log
####################################################

导入用户某个表测试:

1.删除整个表,
drop table test1 purge;
导入整个表含数据:
impdp bys/bys tables=test1 directory=dir_dp dumpfile=bys3.dmp logfile=impdp3.log
导入表定义
impdp bys/bys tables=test1 directory=dir_dp dumpfile=bys3.dmp logfile=impdp2.log content=metadata_only
导入表中数据:
impdp bys/bys tables=test1 directory=dir_dp dumpfile=bys3.dmp logfile=impdp1.log content=data_only

导入用户下所有对象测试:

删除BYS用户下所有表--不删除用户
BYS@ bys3>select * from cat;
no rows selected
##
只导入用户下对象的元数据
impdp bys/bys schemas=bys  directory=dir_dp file=bys5.dmp logfile=bys6.log content=metadata_only
只导入用户下对象的数据
impdp bys/bys schemas=bys  directory=dir_dp file=bys5.dmp logfile=bys7.log content=data_only
导入用户下所有对象及数据:  --不写content=,默认就是ALL
impdp bys/bys schemas=bys  directory=dir_dp file=bys5.dmp logfile=bys8.log

抱歉!评论已关闭.