一,赋予导入,导出权限
oracle导入,导出数据库,要有权限,下面是我把导入,导出的权限付给tank这个用户
grant EXP_FULL_DATABASE,IMP_FULL_DATABASE to tank
二,导出数据库和表
1,导出全库
exp [email protected] file=/home/gaodaima/ora_bak/test.dump full=y
2,导出tank这个用户的表
exp [email protected] file=/home/gaodaima/ora_bak/test_tank.dump owner=tank
3,导出部分表
exp [email protected] file=/home/gaodaima/ora_bak/test_part.dump tables=TEST1,TEST2 compress=y
Export: Release 10.2.0.1.0 – Production on Wed Jun 29 11:51:02 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses WE8ISO8859P1 character set (possible charset conversion)
About to export specified tables via Conventional Path …
. . exporting table TEST1
. . exporting table TEST2 0 rows exported
Export terminated successfully without warnings.
exp [email protected] file=/home/gaodaima/ora_bak/test_part.dump tables=(TEST1,TEST2)
bash: 在未预料的“(”附近出现语法错误
网上有很多tables=(TEST1,TEST2)这样的写法,oracle 10g这样种写法肯定是不行的。
4,导出表中的部分数据
exp [email protected] file=/home/gaodaima/ora_bak/test_part.dump tables=TEST QUERY=\” where city=2 \”
EXP-00019: failed to process parameters, type ‘EXP HELP=Y’ for help
EXP-00000: Export terminated unsuccessfully
不要忘了加上\,不然会报错的,网上有很多是这样写的,QUERY=” where city=2 “是不加\的,但这样写是报错的,至少oracle 10g是报错的。
三,导入数据库表
1,整库导入
imp tank/tank file=/home/gaodaima/ora_bak/test.dump full=y
2,导入部分表
imp tank/tank file=/home/gaodaima/ora_bak/test.dump tables=TEST1,TEST2
如果导出时就是部分表,那就不用指定表了。