expdp导出服务器上的数据到本地磁盘的方法?

expdp导出服务器上的数据到本地磁盘的方法?,第1张

首先,第一步里的connect to orcl identified by orcl是你需要连接的远程数据库orcl(using后面那个)的用户名 / 密码,而不是你本地的用户名密码;

比如你本机叫scott/tiger,需要连接远程服务器上帆闷的exptest/exptest,那你这里就需要些成毁信"connect to exptest identified by exptest",第四步导出的时候写"expdp scott/tiger ......"态余弯;而且如果导出表的话,在表前面还要加上远程那个用户名,例如要导出testTable,则要写成"expdp scott/tiger tables=exptest.testTable ......"这样

其次,要保证你字都没打错,如你建立的link是orlink 还是ytlink,还有第三步里是orcl打成了oacl。

首先创建导出目录: --更详细命令及参数,见: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

写法跟expdp命令一样 如导明改出命令: expdp 用户名/密码 schemas=用户名 directory=exp dumpfile=*.dmp logfile=exp.log

导入命令只需把expdp换成impdp就行 impdp 用户名/密码 schemas=用户名 directory=exp dumpfile=*.dmp logfile=imp.log

注意事项:

首先从导出的机器中传到知槐带要导入数据库的机器上,如Windows可以放在D:\imp 文件夹下(如果两台机器 *** 作系统不同,需使用二进制传输dmp文件)

在要导入数据的数据库创建导入导出目录

SQL>create directory as 'D:\搭芦imp'

3.命令行中开始导入 impdp 用户名/密码 schemas=用户名 directory=exp dumpfile=*.dmp logfile=exp.log


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8269245.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存