一、EXP导出
1、导出表
exp system/password tables=scott.dept,scott.emp file=F:\backup\exp\tab.dmp log=F:\backup\exp\tab.log
exp scott/password tables=dept,emp file=F:\backup\exp\tab.dmp log=F:\backup\exp\tab.log
exp user/pwd file=/dir/xxx.dmp log=xxx.log tables=table1 query=\”where col1=\’…\’and col2 \<…\”
2、导出方案
exp system/password wner=scott file=F:\backup\exp\shchema.dmp log=F:\backup\exp\shchema.log
exp scott/password file=F:\backup\exp\shchema.dmp log=F:\backup\exp\shchema.log
只导出数据对象,不导出数据(rows=n)
exp user/pwd file=/dir/xxx.dmp log=xxx.log wner=user rows=n
3、导出数据库
exp system/password full=y file=F:\backup\exp\full.dmp log=F:\backup\exp\full.log
二、IMP导入
1、导入表
imp scott/password file=F:\backup\exp\tab.dmp log=F:\backup\exp\tab.log tables=dept,emp
imp system/password file=F:\backup\exp\tab.dmp log=F:\backup\exp\tab.log tables=dept,emp fromuser=scott touser=system
2、导入方案
imp scott/password file=F:\backup\exp\shchema.dmp log=F:\backup\exp\shchema.log
imp system/password file=F:\backup\exp\shchema.dmp log=F:\backup\exp\shchema.log fromuser=scott touser=system
3、导入数据库
imp system/password file=F:\backup\exp\full.dmp log=F:\backup\exp\full.log full=y
三、搬移表空间
1、确定自包含表空间集合
conn system/password
execute sys.dbms_tts.transport_set_check('tablespace_name',true)
select * from sys.transport_set_violations;
若有记录,则须删除。
drop index scott.dept_emp_idx;
2、生成搬移表空间集合
alter tablespace users read only;
host exp 'sys/password as sysdba' transport_tablespace=y tablespaces=users file=F:\backup\exp\users.dmp
host copy D:\Oracle\Oracle_10g\oradata\ora10\users.dbf D:\Oracle\Oracle_10g\oradata\test\users.dbf
3、插入表空间到目标数据库
alter system set da_cache_size=20M;
alter system set db_4k_cache_size=4M;
host imp 'sys/password@test as sysdba' transport_tablespace=y file=F:\backup\exp\users.dmp datafiles=D:\Oracle\Oracle_10g\oradata\test\users.dbf
alter tablespace users read write;
数据导出:
1、将数据库中用户的表导出
$exp scott/password file=d:\scott.dmp log=D:\scott.log
2、将数据库完全导出
$exp system/password file=d:\ora10.dmp full=y
3、将数据库中用户的表导出
$exp system/password file=d:\ora10.dmp wner=(system,sys,scott)
4、将数据库中的表导出
$exp scott/password file=d:\scott.dmp tables=(emp,dept)
5、将数据库中的表table1中的字段filed1以"00"打头的数据导出
$exp system/manager file=d:daochu.dmp tables=(table1) query=" where filed1 like '00%'"
对于压缩,既用winzip把dmp文件可以很好的压缩。也可以在上面命令后面 加上 compress=y 来实现。
数据导入:
要先将表彻底删除,然后导入,或删除用户和其所有对象,然后重建用户,再导入。
drop user hjp cascade; --cascade连同用户的对象一起删除
$imp scott/password file=d:\scott.dmp ignore=y destory=y
$imp system/password full=y file=d:\ora10.dmp ignore=y destory=y
$imp scott/password file=d:\scott.dmp tables(emp) ignore=y destroy=y
将用户scott的所有对象导入用户hjp:
1、导出用户scott的所有对象:
$exp scott/password file=D:\scott.dmp log=D:\scott.log
2、将用户hjp在所有空间中的UNLIMITED TABLESPACE权限回收:
create tablespace hjping datafile '/oracle/oradata/ora10/hjping.dbf' size 20M autoextend on next 10M;
create user hjp identified by password default tablespace hjping;
grant connect,resource,imp_full_database to hjp;
revoke unlimited tablespace from hjp;
3、设置默认表空间:
alter user hjp default tablespace hjping;
4、设置默认的表空间无限配额:
alter user hjp quota unlimited on hjping;
5、设置用户对其他表空间的quota为0:
alter user hjp quota 0 on users
6、将数据导入用户hjp:
$imp hjp/password fromuser=scott touser=hjp file=D:\scott.dmp log=D:\scott.log
对用户hjp放开所有表空间
grant unlimited tablespace to hjp;
给用户hjp所有权限
grant resource,connect,dba to hjp;
alter user 用户 quota unlimited on 表空间A;
alter user 用户 quota unlimited on 表空间B;
数据导出:(dos中使用exp help=y查看)
数据导入:(dos中使用imp help=y查看)
使用EXP导出数据时, 出现EXP-00091: Exporting questionable statistics错误
=============================================================================
select * from nls_database_parameters t where t.parameter='NLS_CHARACTERSET';
or
select * from v$nls_parameters where parameter='NLS_CHARACTERSET';
PARAMETER VALUE
----------------- ---------
NLS_CHARACTERSET ZHS16GBK
=============================================================================
然后vi /home/oracle/.bash_profile
===========================================
export NLS_LANG=american_america.ZHS16GBK
===========================================
source /home/oracle/.bash_profile
或直接
export NLS_LANG=american_america.ZHS16GBK
也可以在导出的时候加上statistics=none
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/17012874/viewspace-693301/ ,如需转载,请注明出处,否则将追究法律责任。