2017-01-03 69 views
-1

在創建該表正在錯誤,你能在這方面幫助:錯誤彈出在創建表

CREATE TABLE FIPR_MASTER ( 
    FIPR_Id INT NOT NULL GENERATED ALWAYS 
     AS IDENTITY 
     (START WITH 100 
     INCREMENT BY 1 
     MINVALUE 100 
     NO MAXVALUE 
     NO CYCLE 
     NO CACHE 
     ORDER) PRIMARY KEY, 

    FIPR_NAME VARCHAR2(40) NOT NULL, 
    BU_NAME VARCHAR2(40) NOT NULL, 
    LOCATION VARCHAR2(40) NOT NULL, 
    RECORD_SOURCE_NAME VARCHAR2(200) NOT NULL, 
    PRIORITY_QUEUE VARCHAR2(40) NOT NULL, 
    STATUS VARCHAR2(40) NOT NULL, 
    INDEXING_TYPE VARCHAR2(40) NOT NULL, 
    SOURCE_PATH VARCHAR2(200) NOT NULL, 
    DESTINATION_PATH VARCHAR2(200) NOT NULL, 
    COMMENTS VARCHAR2(200) NOT NULL 
    ) 

錯誤:

CREATE TABLE FIPR_MASTER ( 
    FIPR_Id INT NOT NULL GENERATED ALWAYS 
     AS IDENTITY 
     (START WITH 100 
     INCREMENT BY 1 
     MINVALUE 100 
     NO MAXVALUE 
     NO CYCLE 
     NO CACHE 
     ORDER) , 

    FIPR_NAME VARCHAR2(40) NOT NULL, 
    BU_NAME VARCHAR2(40) NOT NULL, 
    LOCATION VARCHAR2(40) NOT NULL, 
    RECORD_SOURCE_NAME VARCHAR2(200) NOT NULL, 
    PRIORITY_QUEUE VARCHAR2(40) NOT NULL, 
    STATUS VARCHAR2(40) NOT NULL, 
    INDEXING_TYPE VARCHAR2(40) NOT NULL, 
    SOURCE_PATH VARCHAR2(200) NOT NULL, 
    DESTINATION_PATH VARCHAR2(200) NOT NULL, 
    COMMENTS VARCHAR2(200) NOT NULL, PRIMARY KEY(FIPR_Id) 
    ) 
Error report - 
SQL Error: ORA-00907: missing right parenthesis 
00907. 00000 - "missing right parenthesis" 
*Cause:  
*Action: 
+0

哪個Oracle版本?如果我沒記錯,你可以在12c上使用這個 – Aleksej

+0

[在oracle中使用sequence.nextval創建表](http://stackoverflow.com/questions/10613846/create-table-with-sequence-nextval-in -oracle) – XING

+0

如果你想自動增加id,請檢查這個鏈接'http:// stackoverflow.com/questions/11296361/how-to-create-id-with-auto-increment-on-oracle' – XING

回答

2

您與您的DDL的幾個問題聲明:

  1. 標識列必須在任何行內約束(not null計爲行內約束)之前聲明
  2. 看到您聲明這是主鍵(其中一個定義是pk列不爲空),無需明確說明not null
  3. NO和MAXVALUE,CYCLE和CACHE之間應該沒有差距。

下面的語句會爲你工作,假設你在12.1或以上:

CREATE TABLE FIPR_MASTER ( 
    FIPR_Id INT GENERATED ALWAYS 
     AS IDENTITY 
     (START WITH 100 
     INCREMENT BY 1 
     MINVALUE 100 
     NOMAXVALUE 
     NOCYCLE 
     NOCACHE 
     ORDER) PRIMARY KEY, 

    FIPR_NAME VARCHAR2(40) NOT NULL, 
    BU_NAME VARCHAR2(40) NOT NULL, 
    LOCATION VARCHAR2(40) NOT NULL, 
    RECORD_SOURCE_NAME VARCHAR2(200) NOT NULL, 
    PRIORITY_QUEUE VARCHAR2(40) NOT NULL, 
    STATUS VARCHAR2(40) NOT NULL, 
    INDEXING_TYPE VARCHAR2(40) NOT NULL, 
    SOURCE_PATH VARCHAR2(200) NOT NULL, 
    DESTINATION_PATH VARCHAR2(200) NOT NULL, 
    COMMENTS VARCHAR2(200) NOT NULL 
    );