1. 字符集不同

影响:
utf-8->gb 会产生乱码
gbk->utf-8 可兼容,但字符长度不同 (常用中文字符用utf-8编码占用3个字节;GBK、GB2312收编的汉字占2个字节)

建议:导入的数据字符集相同

查询字符集:
SQL> select userenv(‘language’) from dual;

2. 用户的默认临时表空间不是temp

建议:导入前确认用户默认的临时表空间是否为temp,不是则进行remap【临时表空间】

查原用户使用表空间
select distinct tablespace_name from dba_segments where owner=’*’;

查询用户默认表空间、默认临时表空间
select USERNAME,DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE from dba_users where USERNAME=’*’;

导入语句:
impdp “’/ as sysdba’” directory=SJDIR dumpfile=sjzy_DRM_PFM.dmp logfile=sjzy_DRM_PFM.log cluster=n remap_tablespace=IDSE:SJZY,USERS:SJZY,USER_TEMP:TEMP

3. 导出时用当前用户,导入用户sys,报错

解决办法:新建用户后导数据,查询用户原权限,在目标库授予用户权限
1)创建用户:
create user [username] identified by “password” default tablespace [tablespace_name];

2)查询用户的权限:
select ‘grant ‘||t.privilege||’ to ‘||t.grantee||’;’, t.* from dba_sys_privs t where t.grantee=‘username’;
select t.privilege,t.grantee,t.* from dba_tab_privs t where t.grantee=‘METADATA’;

3)查询用户的角色:
select * from dba_role_privs t where t.grantee=‘username’;

4.impdp时报ORA-39082

可重编编译,执行 :
SQL> @?/rdbms/admin/utlrp.sql

5. 导入时用户权限丢失(跟导入顺序有关)

解决办法:原库查询权限,重新授权

查询用户被授予的表的权限:
select ‘grant ‘||t.privilege||’ on ‘||t.owner||’.’||t.table_name||’ to ‘||t.grantee||’;’, t.* from dba_tab_privs t where t.grantee=‘username’;

6. 用户的默认临时profile不是default,导入报错

解决办法:导入前新建同名的profile

查询用户使用的profile:
select username,profile from dba_users where account_status=‘OPEN’;

创建profile:
create profile [profile文件名] limit;

7. 数据量大的索引和约束可用sql创建

$ cat impdp_app_sql.par
userid="/ as sysdba"
directory=EXPDIR
dumpfile=exp_app_%U.dmp
parallel=32
cluster=n
sqlfile=create_index.sql
include=constraint,index

最后修改:2021 年 10 月 02 日
如果觉得我的文章对你有用,请随意赞赏