数据导出:
1 将数据库TEST完全导出,用户名system 密码password 导出到/home/oracle/databackup中
exp system/password@TEST file=/home/oracle/databack/test.dmp full=y
2 将数据库中system用户与sys用户的表导出
exp system/password@TEST file=/home/oracle/databack/system_sys.dmp owner=(system,sys)
3 将数据库中的表table1,table2,table3导出
exp system/password@TEST file=/home/oracle/databack/tables.dmp tables=(table1,table2,table3)
4 将数据库中的表table1中的字段filed1以"xh"打头的数据导出
exp system/password@TEST file=/home/oracle/databack/table1_xh.dmp tables=(table1) query=" where filed1 like 'xh%'"
上面是常用的导出,对于压缩,既用gzip或者bzip2把dmp文件可以很好的压缩。
也可以在上面命令后面 加上 compress=y 来实现。
数据的导入
1 将/home/oracle/databack/test.dmp中的数据导入 TEST数据库中。
imp system/password@test file=/home/oracle/databack/test.dmp
imp system/password@test full=y file=/home/oracle/databack/test.dmp ignore=y
上面可能有点问题,因为有的表已经存在,然后它就报错,对该表就不进行导入。
在后面加上 ignore=y 就可以了,忽略错误信息,正确表可正常导入。
2 将/home/oracle/databack/tables.dmp中的表table1 导入
imp system/password@TEST /home/oracle/databack/test.dmp tables=(table1)
3.如果是某个用户的所有数据导入,可以先将这个用户从数据库中删除,并删除其所有数据,重建用户。
再导入数据,避免已存在的信息导致导入失败。
注:ORA-1455 可能是导出工具的客户端版本低于服务器版本所致,只需将ORACLE客户端升级到与服务器相同版本或更高版本即可。
oracle 11.2.0.1.0 版本客户端导出11g数据时可能遇到 ORA-01455: 转换列溢出整数数据类型
这个错误可能时这个版本客户端的BUG,下载11.2.0.3.0客户端,即可解决问题。