oracle外部表kup-04040,【故障处理】19c PDB中创建外部表时,出现KUP-04040报错
【故障描述】
使用網(wǎng)絡(luò)連接的方式登錄19c的PDB,然后創(chuàng)建oracle_loader驅(qū)動(dòng)模式的外部表。創(chuàng)建成功后,在檢索數(shù)據(jù)時(shí),出現(xiàn)KUP-04040的報(bào)錯(cuò),過程如下:
[oracle@sdedu ~]$ sqlplus sys/oracle@pdb1 as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Mar 7 18:12:34 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> create directory dmp_dir as '/home/oracle/ext_table/';
Directory created.
SQL> CREATE TABLE emp_load
2 (
3 first_name CHAR(15),
4 last_name CHAR(20),
5 year_of_birth CHAR(4)
6 )
7 ORGANIZATION EXTERNAL
8 (
9 TYPE ORACLE_LOADER
10 DEFAULT DIRECTORY dmp_dir
11 ACCESS PARAMETERS
12 (
13 RECORDS DELIMITED BY '|'
14 DISABLE_DIRECTORY_LINK_CHECK
15 FIELDS TERMINATED BY ','
16 (
17 first_name CHAR(7),
18 last_name CHAR(8),
19 year_of_birth CHAR(4))
20 )
21 LOCATION ('info.dat')
22 )
23 REJECT LIMIT UNLIMITED
24 ;
Table created.
SQL> select * from emp_load;
select * from emp_load
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file info.dat in DMP_DIR not found
【解決過程】
經(jīng)過測(cè)試發(fā)現(xiàn),如果在session中切換容器到pdb1中,訪問就是正常的。
SQL> alter session set container=pdb1;
Session altered.
SQL> select * from emp_load;
FIRST_NAME LAST_NAME YEAR
--------------- -------------------- ----
Alvin Tolliver 1976
Kenneth Baer 1963
Mary Dube 1973
SQL>
這個(gè)報(bào)錯(cuò),和可能是由于文件和目錄權(quán)限導(dǎo)致,因此檢查一下權(quán)限:
[oracle@sdedu ~]$ ls -alt ext_table/
total 24
drwx------. 29 oracle oinstall 4096 Mar 7 21:10 ..
drwxrwxrwx 2 oracle oinstall 100 Mar 7 18:51 .
-rwxrwxrwx 1 oracle oinstall 55 Mar 7 17:59 INFO.DAT
[oracle@sdedu ~]$
從文件的權(quán)限沒有問題,目錄的權(quán)限也是沒有問題。但為啥還是不行呢?
索性換一下目錄來出來吧。
我們使用pdb1默認(rèn)的DATA_PUMP_DIR目錄來進(jìn)行外部表的創(chuàng)建。
/u01/app/oracle/admin/SS19C/dpdump/ADB4AF11A2A07F0BE0530A0200C001E6
此時(shí)發(fā)現(xiàn)成功了!
[oracle@sdedu ADB4AF11A2A07F0BE0530A0200C001E6]$ sqlplus sys/oracle@pdb1 as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Mar 7 21:31:24 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> drop table emp_load;
Table dropped.
SQL> CREATE TABLE emp_load
2 (
3 first_name CHAR(15),
4 last_name CHAR(20),
5 year_of_birth CHAR(4)
6 )
7 ORGANIZATION EXTERNAL
8 (
9 TYPE ORACLE_LOADER
10 DEFAULT DIRECTORY DATA_PUMP_DIR
11 ACCESS PARAMETERS
12 (
13 RECORDS DELIMITED BY '|'
14 FIELDS TERMINATED BY ','
15 (
16 first_name CHAR(7),
17 last_name CHAR(8),
18 year_of_birth CHAR(4))
19 )
20 LOCATION ('INFO.DAT')
21 )
22 REJECT LIMIT UNLIMITED
23 ;
Table created.
SQL> select * from emp_load;
FIRST_NAME LAST_NAME YEAR
--------------- -------------------- ----
Alvin Tolliver 1976
Kenneth Baer 1963
Mary Dube 1973
SQL>
換一個(gè)目錄在測(cè)試一下,也是成功了,此時(shí)發(fā)現(xiàn)ORIGIN_CON_ID也為1,1代表根容器。看來要想成功,ORIGIN_CON_ID列必須為1,也就是從根容器繼承過來的。
[oracle@sdedu ext_table]$ sqlplus sys/oracle@pdb1 as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Mar 7 22:46:22 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select * from dba_directories where directory_name='SDO_DIR_ADMIN';
OWNER DIRECTORY_NAME DIRECTORY_PATH ORIGIN_CON_ID
-------- --------------- ------------------------------------------------- -------------
SYS SDO_DIR_ADMIN /u01/app/oracle/product/19.3.0/dbhome_1/md/admin 1
1 rows selected.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 PDB1 READ WRITE NO
SQL> !cp /home/oracle/ext_table/INFO.DAT /u01/app/oracle/product/19.3.0/dbhome_1/md/admin/
SQL> drop table emp_load;
Table dropped.
SQL> CREATE TABLE emp_load
2 (
3 first_name CHAR(15),
4 last_name CHAR(20),
5 year_of_birth CHAR(4)
6 )
7 ORGANIZATION EXTERNAL
8 (
9 TYPE ORACLE_LOADER
10 DEFAULT DIRECTORY SDO_DIR_ADMIN
11 ACCESS PARAMETERS
12 (
13 RECORDS DELIMITED BY '|'
14 FIELDS TERMINATED BY ','
15 (
16 first_name CHAR(7),
17 last_name CHAR(8),
18 year_of_birth CHAR(4))
19 )
20 LOCATION ('INFO.DAT')
21 )
22 REJECT LIMIT UNLIMITED
23 ;
Table created.
SQL> select * from emp_load;
FIRST_NAME LAST_NAME YEAR
--------------- -------------------- ----
Alvin Tolliver 1976
Kenneth Baer 1963
Mary Dube 1973
SQL>
在創(chuàng)建Directory時(shí),是無法指定ORIGIN_CON_ID來源的。在那個(gè)容器創(chuàng)建,就會(huì)是那個(gè)容器的ID。這種策略很可能是BUG。
最終,由于目錄權(quán)限問題導(dǎo)致創(chuàng)建外部表失敗,此時(shí)我們可以使用PDB默認(rèn)的DUMP目錄,也就是ORIGIN_CON_ID為1的目錄,來避免這個(gè)錯(cuò)誤。
【參考資料】
總結(jié)
以上是生活随笔為你收集整理的oracle外部表kup-04040,【故障处理】19c PDB中创建外部表时,出现KUP-04040报错的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [MS Sql Server术语解释]预
- 下一篇: 黑客攻防:关于工业网络安全的那些事