- 表方式,将指定表的数据导出/导入
Windows: set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
- 用户方式,将指定用户的所有对象及数据导出/导入
代码
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log owner=(xx, yy)
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log owner=(xx, yy)
只导出数据对象,不导出数据 (rows=n )
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log owner=user rows=n
导入:
代码
imp user/pwd file=/dir/xxx.dmp log=xxx.log fromuser=dbuser touser=dbuser2 commit=y ignore=y
imp user/pwd file=/dir/xxx.dmp log=xxx.log fromuser=dbuser touser=dbuser2 commit=y ignore=y
- 全库方式,将数据库中的所有对象导出/导入导出
代码 导出全库必须用system/manger
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log full=y commit=y ignore=y
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log full=y commit=y ignore=y
导入:
代码
$ imp user/pwd file=/dir/xxx.dmp log=xxx.log fromuser=dbuser touser=dbuser2
imp magic/oracle file=/home/oracle/tablefull.dmp log=imp.log fromuser=sguap207 touser=magic ignore=y statistics=none
导出一张或几张表:
代码
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1,table2
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1,table2
如果是分区表
代码
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1:tablespaces1,table2:tablespaces2
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1:tablespaces1,table2:tablespaces2
导出某张表的部分数据
代码
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1 query=\”where col1=\’…\’and col2 \<…\”
$ exp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1 query=\”where col1=\’…\’and col2 \<…\”
导入:
导入一张或几张表
代码
$ imp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1,table2 fromuser=dbuser touser=dbuser2 commit=y ignore=y
$ imp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1,table2 fromuser=dbuser touser=dbuser2 commit=y ignore=y
如果是分区表
代码
$ imp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1:tablespaces1,table2:tablespaces2 fromuser=dbuser touser=dbuser2 commit=y ignore=y
$ imp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1:tablespaces1,table2:tablespaces2 fromuser=dbuser touser=dbuser2 commit=y ignore=y