Oracle 异常处理汇总
1、plsql无法连接
安装oracle,中间录入密码,用户是:sys,pass: 录入的密码。
连接数据库,建议创建新的用户,最好别直接用sys
安装完毕,则需要配置Net Configration Assistant,才能通过pl/sql连接
确保服务监听服务已经启动
2、遇到ORACLE错误12514
解决方案:
1) 找到监听文件
C:\Oracle\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
打开:
# listener.ora Network Configuration File: C:\Oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools. LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = WIN-L7MD6EPHO8Q.localdomain)(PORT = 1521))
)
) ADR_BASE_LISTENER = C:\Oracle
修改为:
# listener.ora Network Configuration File: C:\Oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools. LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = WIN-L7MD6EPHO8Q.localdomain)(PORT = 1521))
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = \product\11.2.0\dbhome_1)
(SID_NAME = orcl)
)
) ADR_BASE_LISTENER = C:\Oracle
ORACLE_HOME: oracle安装目录
GLOBAL_DBNAME: 实例名,默认为orcl
2) 重启监听器,当然可以在windows服务中重启
打开cmd,执行:
lsnrctl stop // 关闭
lsnrctl start // 启动
3、oracle 11g如果遇到这个问题12514
解决方案:
1、SID_NAME改为具体的实例名,如:orcl
2、删除 (PROGRAM = extproc)
# listener.ora Network Configuration File: D:\oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools. SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = orcl)
(ORACLE_HOME = D:\oracle\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
) SID_LIST_ORCL =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\oracle\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
) LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.30.134)(PORT = 1521))
)
) ADR_BASE_LISTENER = D:\oracle
4、imp还原数据库时报错:错误12514
IMP-00058: 遇到 ORACLE 错误 12514
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
IMP-00000: 未成功终止导入
注意导入的实例名是否正确,可参考上述解决方案。
5、删除用户时提示:无法删除当前连接的用户
第 1 行出现错误:
ORA-01940: 无法删除当前连接的用户
说明,当前存在用户的session.
解决方案:
1、首先查找session,确定是那个进程引用
select username,sid,serial# from v$session
或者查询增加用户的过滤条件,只查该用户的
select username,sid,serial# from v$session where username='DEMO'
2、杀死相应的session
alter system kill session'$sid,$serial';
3、强制删除用户
drop user demo cascade;
6、导入数据时遇到 ORACLE 错误 959
IMP-00003: 遇到 ORACLE 错误 959
ORA-00959: 表空间 'xxx' 不存在
IMP-00017: 由于 ORACLE 错误 959, 以下语句失败:
解决方案:
1、导入前,先创建表空间
create tablespace demo datafile 'D:\oracle\data\demo.dbf' size 100M autoextend on;
2、指定用户该表空间不受限
alter user xxx quota unlimited on demo;//后面的demo是表空间名
3、然后再imp即可
注意导入时一定要指定log,便于分析解决