Oracle数据备份与恢复

一.cmd命令导出导入数据(备份与恢复)

	${mangUserName}:管理员用户
	${mangPassword}:管理员密码
	${userName}:用户名,与管理员用户可以相同
	${filePath}:文件路径,建议以.dmp结尾

1)整库导出

		exp ${mangUserName}/${mangPassword} full=y; #参数full表示整库导出。导出后会在当前目录下生成一个EXPDAT.DMP的文件,此文件为备份文件。

如果想导出数据到指定位置,并且取个名字,需要添加file参数。例如:

		exp system/123456 file= C:\person.dmp full=y;

2)整库导入

		imp ${mangUserName}/${mangPassword} full=y file=${filePath}

3)按用户导出导入

3.1)按用户导出:

			exp ${mangUserName}/${mangPassword} owner=${userName} file=${filePath}

3.2)按用户导入:

			imp ${mangUserName}/${mangPassword} file=${filePath} fromuser=${oriUserName} [ignore=y]

4)按表导出导入

4.1)按表导出:
			exp ${mangUserName}/${mangPassword} file=${filePath} tables={tb1,tb2,...}
4.2)按表导入:
			imp ${mangUserName}/${mangPassword} file =${filePath} tables={tb1,tb2,...}
4.3)可以加上"rows=n"条件只导出结构,不导出数据

二.查看exp导出的dmp文件编码

使用下面命令获得编码数字

	cat ${fileName}|od -x|head -1|awk '{print $2 $3}'|cut -c 3-6

如编码数字为0345,sqlplus连接数据库查看编码

	select nls_charset_name(to_number('0345','xxxx')) from dual;
posted @ 2020-08-12 23:29  周建林  阅读(214)  评论(0编辑  收藏  举报