首先:
cd oracle\product\10.2.0\db_1\bin
导出(将数据库db1 中用户user,user1下的表全部导出,密码pswd,导出文件d:\db1.dmp,日志d:\db1_exp.log):
exp user/pswd@db1 file=d:\db1.dmp owner=(user,user1) log=d:\db1_exp.log
导入(将数据库db1 中用户user,user1下的表全部导入,密码pswd,导入文件d:\db1.dmp,日志d:\db1_imp.log):
imp user/pswd@db1 file=d:\db1.dmp fromuser=(user,user1) log=d:\db1_imp.log
其他情况:
导出:
1、 将数据库test完全导出,用户名system 密码manager 导出到d:/test_exp.dmp中
exp system/manager@test file=d:/test_exp.dmp full=y
2 、将数据库中的t1、t2导出
exp system/manager@test file= d:/test_exp.dmp tables=(t1,t2)
3、将数据库中的表t1中的字段filed1以"00"打头的数据导出
exp system/manager@test file=d:/test_exp.dmp tables=(t1) query=/" where filed1 like 00%/"
上面是常用的导出,对于压缩,用winzip可以把dmp文件可以很好的压缩。也可以在上面命令后面加上 compress=y 来实现。
导入:
1 、将d:/daochu.dmp 中的数据导入 test数据库中。
imp system/manager@test file=d:/daochu.dmp imp aichannel/aichannel@hust full=y file=file= d:/data/newsmgnt.dmp ignore=y
注:如果因为有的表已经存在出现报错,在后面加上 ignore=y 就可以了。
2 、将d:/daochu.dmp中的表table1 导入
imp system/manager@test file=d:/daochu.dmp tables=(table1)
注意:
1、操作者要有足够的权限,权限不够它会提示。
2、数据库需要可以连接。可以用tnsping test 来获得数据库test能否连上。
参考:
http://www.cnblogs.com/fjfzhkb/archive/2007/09/03/879807.html
http://blog.youkuaiyun.com/usthycp/article/details/3176451