Oracle使用imp导入dmp文件

  dmp文件导入到Oracle数据库一般有impdp和imp,如果impdp不好用时,就需要使用到imp来进行数据导入。

(1).创建用户

  这一步完全根据个人需要是否创建新的用户

create user [用户名] identified by [密码] ;

(2).创建表空间

  在创建表空间前可以使用如下命令查看以往表空间文件存放的位置:

select * from dba_data_files;

  最好在看下文件系统是否有足够的空间,再之后就是创建表空间了。

CREATE TABLESPACE [表空间名] DATAFILE '[表空间文件存放的绝对地址,文件格式为.dbf]' SIZE 1G AUTOEXTEND ON NEXT 50M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K;

(3).用户授权

  如果是已有用户可以使用如下两条命令中的一条:

alter user [用户名] quota unlimited on [表空间];  
alter user [用户名] quota *M on [表空间];  

  如果是新建的用户需要根据自己的需求选择如下命令中的一部分:

grant create session to [用户名];  
grant create table to [用户名];
grant create tablespace to [用户名];  
grant create view to [用户名];  
grant connect,resource to [用户名];  
grant create any sequence to [用户名];  
grant create any table to [用户名];  
grant delete any table to [用户名];  
grant insert any table to [用户名];  
grant select any table to [用户名];  
grant unlimited tablespace to [用户名];  
grant execute any procedure to [用户名];  
grant update any table to [用户名];  
grant create any view to [用户名]; 

(4).imp导入dmp文件

imp [用户]/[密码]  file=文件路径 full=y ignore=y;
  • 该命令需要在cmd的dos命令窗口直接执行,而不是sqlplus.exe
  • full=y 是导入文件中全部内容
  • ignore=y相当于,如果没有的表,创建并倒入数据,如果已经有的表,忽略创建的,但不忽略倒入

报错信息:

1、  import done in US7ASCII character set and AL16UTF16 NCHAR character set

  import server uses ZHS16GBK character set (possible charset conversion)

  export client uses ZHS16GBK character set (possible charset conversion)

  Linux环境下报这个错误最好可以使用指定编码重新导出,但也可以通过设置相应的编码进行临时处理:

    set LANG=cn_ZH.UTF8

    set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

    export LANG=cn_ZH.UTF8

    export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

2、IMP-00015: following statement failed because the object already exists:

  这个就是缺少参数ignore=y

 

参考资料:https://www.lmlphp.com/user/12056/article/item/440209/

     https://www.cnblogs.com/cnetsa/p/12790240.html

posted @ 2023-05-05 12:05  苦逼运维  阅读(4206)  评论(0编辑  收藏  举报