2016-06-13 32 views
0

我想創建外部表,但出現錯誤。選擇外部表時出現ORA錯誤

下面是一個使用創建外部表的代碼,

CREATE TABLE "emp_ext" 
(
    "EMPNO" NUMBER(6), 
    "ENAME" VARCHAR2(20), 
    "JOB" VARCHAR2(25), 
    "MGR" NUMBER(6), 
    "HIRE_DATE" DATE, 
    "SAL" NUMBER(8,2), 
    "COMM" NUMBER(2,2), 
    "DEPTNO" NUMBER(4) 
) 
ORGANIZATION external 
(
    TYPE oracle_loader 
    DEFAULT DIRECTORY EXTDIR 
    ACCESS PARAMETERS 
(
    RECORDS DELIMITED BY NEWLINE CHARACTERSET US7ASCII 
    BADFILE 'EXTDIR':'employees.bad' 
    LOGFILE 'employees.log_xt' 
    READSIZE 1048576 
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM 
    REJECT ROWS WITH ALL NULL FIELDS 
    (
    "EMPLOYEE_ID" CHAR(255) 
    TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', 
    "ENAME" CHAR(255) 
    TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', 
    "JOB" CHAR(255) 
    TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', 
    "HIRE_DATE" CHAR(255) 
    TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', 
    "SAL" CHAR(255) 
    TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', 
    "COMM" CHAR(255) 
    TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', 
    "DEPTNO" CHAR(255) 
    TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' 
) 
) 
    location 
    (
    'datafile.txt' 
) 
) 

我已經讀/寫權限到外部目錄。

表已創建。當我嘗試做從「emp_ext」 SELECT *,我得到以下錯誤

SQL> select * from "emp_ext"; 
select * from "emp_ext" 
* 
ERROR at line 1: 
ORA-29913: error in executing ODCIEXTTABLEOPEN callout 
ORA-29400: data cartridge error 
KUP-04043: table column not found in external source: EMPNO 
ORA-06512: at "SYS.ORACLE_LOADER", line 19 
+0

錯誤消息看起來很清楚,不是嗎?這個datefile.txt的樣本在哪裏?表定義中有EMPNO,但文件的行/列定義中有EMPLOYEE_ID。 – OldProgrammer

回答

0

CREATE TABLE指定的第一個字段是EMPNO,但在記錄定義中指定的第一個字段是EMPLOYEE_ID。這些必須匹配。挑一個或另一個。

祝你好運。

+0

非常感謝。問題解決了。 –

0

我猜你應該改變

"EMPLOYEE_ID" CHAR(255) 

"EMPNO" CHAR(255) 

,其中從MGR正在添加數據?

+1

非常感謝。問題解決了。 –

+0

@SathishKumar不客氣。將問題標記爲已回答。 – vercelli

相關問題