Oracle数据库报错

1、数据库锁表

1. 首先查看数据库中哪些表被锁了,找到session ID:
    使用sql:
      select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;
        OWNER :数据表的所有者用户
        OBJECT_NAME: 被锁住的表名
        SESSION_ID: 会话ID
        LOCKED_MODE: 锁级别
          锁级别分为6级:
            1级锁有:Select
            2级锁有:Select for update,Lock For Update,Lock Row Share
            3级锁有:Insert, Update, Delete, Lock Row Exclusive
            4级锁有:Create Index, Lock Share
            5级锁有:Lock Share Row Exclusive 
            6级锁有:Alter table, Drop table, Drop Index, Truncate table, Lock Exclusive
2.再执行该语句,查看会话id
    select b.username,b.sid,b.serial#,logon_time  from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;
3.杀会话
    alter system kill session 'sid,serial#';
    例子:
        alter system kill session '20,30153';       #这个是我刚才杀死会话前的执行语句
        如果有ora-00031错误,则在后面加immediate;
        alter system kill session '20,30153' immediate;

 2、备份数据库 exp/imp 导出/导入数据 报错

.dmp数据导入到目标数据库报错:
IMP-00019: row rejected due to ORACLE error 12899 
IMP-00003: ORACLE error 12899 encountered 
ORA-12899: value too large for column "CLCS"."BATCH_REPORT"."FILE_NAME" (actual: 41, maximum: 40)

出现这种问题是因为老数据库的字符集和备份数据库的字符集不一样。

查看数据库的字符集:
    select userenv('language') from dual;
查到老数据库是ZHS16GBK,而备份数据库是utf-8

用以下命令修改本机库字符集:
    SHUTDOWN IMMEDIATE
    STARTUP MOUNT
    ALTER SYSTEM ENABLE RESTRICTED SESSION;
    ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
    ALTER SYSTEM SET AQ_TM_PROCESSES=0;
    ALTER DATABASE OPEN
    ALTER DATABASE CHARACTER SET INTERNAL_USE ZHS16GBK;
    SHUTDOWN IMMEDIATE
    STARTUP

设置后导入成功!
还有注意一点就是建表空间和用户时要和生产库的表空间名称、数据文件名称、用户名、密码都要一致;

 

posted @ 2022-06-28 09:40  等风来~~  阅读(112)  评论(0编辑  收藏  举报