学习笔记(六):oracle数据库备份

本文详细介绍了如何使用exp和expdp命令导出Oracle数据库,包括完整和简略的方式,并讲解了导入前的准备,如创建表空间和用户,以及授权。此外,还提供了imp和impdp的导入方法,特别提到了remap_schema和remap_tablespace参数的应用,以及解决空表不被导出的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、导出数据库

1、exp方式

打开cmd,输入命令。

--简略
cmd> exp test(用户名)/123456(密码) file=D:\test.dmp owner=用户名

--完整
cmd> exp test(用户名)/123456(密码)@127.0.0.1(ip地址):1521(端口号)/orcl file=D:\test.dmp owner=用户名

2、expdp方式

打开cmd,输入命令。

cmd> expdp test(用户名)/123456(密码) directory=dmp_dir dumpfile=test.dmp full=y;

二、导入前准备

1、创建表空间

create tablespace test datafile 'D:\app\oracle\test.dbf' size 1024m autoextend on next 50m maxsize 31G;

2、创建用户

create user test(用户名) identified by 123456(密码) default tablespace test(表空间名) temporary tablespace TEMP(临时表空间名);

3、用户授权

grant connect,resource,dba to test(用户名);

三、导入数据库

1、imp导入

cmd> imp test(用户名)/123456(密码) file=D:\test.dmp full=y;

2、impdp导入

<!-- remap_schema:该参数用于将源模式中的所有对象转载到目标模式中,语法为:remap_schema=source_schema:target_schema -->

<!-- remap_tablespace:该参数用于指定导入时更改表空间名称,语法为:remap_tablespace=source_tablespace:target_tablespace -->

<!-- 当模式和表空间一致时,可不写 -->

cmd> impdp test(用户名)/123456(密码) directory=dump_dir dumpfile=D:\test.dmp remap_schema=test1:test remap_tablespace=test1:test full=y;

【补充】exp/imp 不导出空表的解决方案

查询空表生成sql语句,复制结果执行即可。

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值