天天看点

Oracle 通过 exp/imp 备份数据库

一、导出数据库

1.已管理员身份运行cmd

Oracle 通过 exp/imp 备份数据库

2.输入命令:

cmd> exp test/[email protected] file=D:\oracle_bf\xzmis02.dmp owner=tablename
           

注意:此处账号需要有dba权限

Oracle 通过 exp/imp 备份数据库

3.导出中

Oracle 通过 exp/imp 备份数据库

4.导出成功

Oracle 通过 exp/imp 备份数据库

二、导入数据

1.导入数据:imp 用户名/密码@服务名 file=导入的dmp文件路径 full=y

cmd> imp test/[email protected] file=D:\oracle_bf\xzmis02.dmp full=y
           

注意:要将数据导入到哪个库下就使用那个库对应的账号,比如需要将数据导入到 test2 中,就需要输入 test2 的账号密码

三、exp/imp 不导出空表的解决方案

1.查询空表生成sql语句

sql> select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows IS NULL;
           

2.复制结果执行即可