记录oracle多dump文件imp导入 (centos7)

来源:互联网 发布:什么是淘宝转化率 编辑:程序博客网 时间:2024/05/19 09:12
1执行建表sql

create table TB_MONTHCONSUME
(
  countserial   CHAR(6) not null,
  consumeserial NUMBER not null,
  consumecount  NUMBER not null,
  cardno        VARCHAR2(20) not null,
  consume       NUMBER not null,
  remaintimes   NUMBER(5),
  balance       NUMBER,
  consumedate   DATE not null,
  consumetype   NUMBER(2) not null,
  verifycode    CHAR(8) not null,
  drivercardno  CHAR(12),
  lineno        VARCHAR2(20) not null,
  busno         CHAR(6) not null,
  psam          CHAR(12) not null,
  flag          NUMBER,
  discount      CHAR(4)
)

2 上传文件,执行导入语句
hr/hr 是之前数据库有的用户名和密码; tables=后面接表名如果是多个表,用“,表名“补充
imp hr/hr file=/home/oracle/database/temp/20170513.dmp  ignore=y tables=TB_MONTHCONSUME buffer=100000000  statistics=none

然后报错了,应该是dmp文件里面有表空间的信息,当前数据库没有;
建表空间和用户;

问题1 :tablespace 'DATA_TRAN' does not exist

创建临时表空间:

--查询临时表空间文件的绝对路径。如果需要的话,可以通过查询来写定绝对路径。一般用${ORACLE_HOME}就可以了
select name from v$tempfile;
create temporary tablespace new_temp tempfile '/u01/app/oracle/oradata/review/new_temp.dbf' size 100m reuse autoextend on next 200m maxsize unlimited;
创建表空间:

--查询用户表空间文件的绝对路径:
select name from v$datafile;
create tablespace DATA_TRAN datafile '/u01/app/oracle/oradata/review/data_tran.dbf' size 100M reuse autoextend on next 40M maxsize unlimited default storage(initial 128k next 128k minextents 2 maxextents unlimited);
创建用户和密码,指定上边创建的临时表空间和表空间

create user newUser identified by newUser default tablespace DATA_TRAN temporary tablespace new_temp;
赋予权限

grant dba to newUser;
grant connect,resource to newUser;
grant select any table to newUser;
grant delete any table to newUser;
grant update any table to newUser;
grant insert any table to newUser;
grant sysdba to newUser;

导入文件 

imp newUser/newUser file=/home/oracle/database/temp/20170513.dmp ignore=y tables=TB_MONTHCONSUME buffer=100000000  statistics=none

问题2:oracle imp卡住了解决方法

使用imp导入数据,偶尔到一个表会一直卡住。

查看表空间,alert日志,都没有问题,最后发现是游标数不够用了。

查看当前使用的游标
select count(*) from v$open_cursor ;

查看设置的最大游标
show parameter open_cursors;

如果当前设置的最大游标数小于使用的游标数,造成游标被锁,卡住了

将游标设置大一些
alter system set open_cursors=1000 scope=both;

问题3: 导入第二个dump文件时报错:ORA-04098: trigger invalid and failed re-validation

后来找到原因是:第一个文件导入后多了两个触发器;没细看触发器内容;
尝试关闭触发器导入成功,这个时候触发器又启用了,如果要继续导入,先关闭触发器



原创粉丝点击