在运行ORACLE_LOADER类型的外部表查询时出现这个错误。
[@more@]
数据库的情况比较复杂,简单描述一下。数据库是安装在操作系统oracle用户下,默认组为oinstall,当前使用的是操作系统用户tingkun.yang,同样是oinstall组,因此当前用户可以用SYSDBA身份登录数据库。
以当前用户tingkun.yang运行sqlplus连接数据库,创建目录和外部表,在读取外部表时报错:
[tingkun.yang@enmoteam2 ~]$ id
uid=505(tingkun.yang) gid=501(oinstall) groups=501(oinstall),502(dba)
[tingkun.yang@enmoteam2 ~]$ ps -ef|grep lgwr
oracle 1552 1 0 Sep07 ? 00:04:14 ora_lgwr_enmot2
505 28312 28185 0 22:52 pts/0 00:00:00 grep lgwr
[tingkun.yang@enmoteam2 ~]$ sqlplus olasuser/olasuser
SQL*Plus: Release 11.2.0.3.0 Production on Sat Nov 24 22:53:06 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create directory d_alert as '/home/oracle/sqlldr';
Directory created.
SQL> create table t_alert
2 (text varchar2(4000))
3 organization external
4 (type oracle_loader
5 default directory d_alert
6 access parameters
7 (records delimited by newline
8 fields (text (1:255) char))
9 location ('alert_enmot2.log'));
Table created.
SQL> select * from t_alert where rownum = 1;
select * from t_alert where rownum = 1
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file alert_enmot2.log in D_ALERT not found
查询MOS发现所有的已知问题都和当前的现象不同,该文件已经存在于指定的目录下,甚至在这个目录下,错误日志已经生成:
[oracle@enmoteam2 sqlldr]$ pwd
/home/oracle/sqlldr
[oracle@enmoteam2 sqlldr]$ ls -l
total 664
-rw-rw-rw- 1 oracle oinstall 674964 Nov 22 14:06 alert_enmot2.log
-rw-r--r-- 1 oracle oinstall 95 Nov 24 22:54 T_ALERT_28321.log
[oracle@enmoteam2 sqlldr]$ more T_ALERT_28321.log
LOG file opened at 11/24/12 22:54:52
KUP-04040: file alert_enmot2.log in D_ALERT not found
经过多次测试发现,如果使用oracle用户启动sqlplus,则可以读取t_alert表:
[oracle@enmoteam2 ~]$ id
uid=502(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),506(asmdba)
[oracle@enmoteam2 ~]$ sqlplus olasuser/olasuser
SQL*Plus: Release 11.2.0.3.0 Production on Sat Nov 24 22:58:57 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from t_alert where rownum = 1;
TEXT
----------------------------------------------------
Fri Aug 10 13:39:20 2012
一直认为,这种DIRECTORY的读取,使用的是oracle用户的身份和权限,和登录的操作系统用户无关。没有想到,Oracle是根据操作系统用户是否有权限访问这个文件作为外部表访问的条件。但是外部表的日志并没有受权限的控制而已经产生了。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4227/viewspace-1060811/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/4227/viewspace-1060811/