oracle备份数据库

1. 连接远程数据库
打开cmd
执行sqlplus/nolog
执行connect 用户名/密码@IP:端口/服务名
例:connect system/ETYY@114.116.211.102:1521/ETYY
2. 创建directory,首先要保证存在该文件夹
create directory 名字 as '路径';
例:create directory expdir as 'E:\expdir';
3. 授权
grant read,write on directory expdir to 用户;
例:grant read,write on directory expdir to yl_etyy;
4. 执行导出
    1)exp 用户名/密码@IP:端口/服务名 file=路径:文件名 owner=(用户),只导出该用户下的表
    例:exp yl_etyy/sx_etyy@114.116.211.102:1521/ETYY file=E:\20220224.dmp owner=(yl_etyy)
    2)expdp 用户名/密码@IP:端口/服务名 schemas=用户名 directory=expdir dumpfile=文件名
    例:expdp yl_etyy/sx_etyy@114.116.211.102:1521/ETYY schemas=yl_etyy directory=expdir dumpfile=20220224.dmp
说明:第二种方式在远程备份的时候执行报错了,错误信息:

连接到: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Pr

With the Partitioning, OLAP, Data Mining and Real Application Testing

ORA-39002: 操作无效

ORA-39070: 无法打开日志文件。

ORA-29283: 文件操作无效

ORA-06512: 在 "SYS.UTL_FILE", line 488

ORA-29283: 文件操作无效等类似的错误。

网上查询资料解释是:expdp只能在服务器端执行,在客户端执行会出现上述错误

参考另一篇笔记:expdp,impdp导出导入远程数据库到本地

5. oracle导出导入指定表

从源数据库导出:

exp user1/pwd@server1 file=c:\temp\exp.dmp tables=(table1, table2)
导入到目标数据库:

imp user2/pwd@server2 file=c:\temp\exp.dmp tables=(table1, table2)

导入到指定用户下:
imp user/pwd@IP:端口/服务名 file=c:\temp\exp.dmp fromuser=用户名 touser=用户名





posted @ 2022-02-24 21:52  Chesters  阅读(995)  评论(0编辑  收藏  举报