2014-04-28 55 views
0

請幫我用這段代碼。我嘗試創建一個表,但它保持坡平了錯誤ORA-00904:無效的標識符ORA-00904無效標識符代碼

CREATE TABLE tblParentMaster 
    (HOHCodeid VARCHAR2(10), 
    Parent1 VARCHAR2(10), 
    Address VARCHAR2(30), 
    Home_Phone_Number CHAR(10), 
    Address1 VARCHAR2(30), 
    City VARCHAR2(20), 
    States CHAR(2), 
    Zip CHAR(5), 
    Parent2Code VARCHAR2(10), 
    Parent2 VARCHAR2(10), 
    Address2 VARCHAR2(30), 
    Volunteer CHAR(1) DEFAULT 'N', 
    Email VARCHAR2(20), 
     CONSTRAINT pk_tblParentMaster_HOHCode PRIMARY KEY (HOHCode), 
     CONSTRAINT nn_tblParentMaster_Parent1 NOT NULL (Parent1), 
     CONSTRAINT ck_tblParentMaster_Volunteer CHECK (Volunteer IN ('Y', 'N')) 
); 

回答

1

這不是你如何聲明一個非空約束。您可以有一個名爲約束,爲shown in the documentation

... 
Parent1 VARCHAR2(10), 
... 
CONSTRAINT nn_tblParentMaster_Parent1 CHECK (Parent1 is NOT NULL) 
... 

或者宣佈其在線,它不會有一個好聽的名字:

... 
Parent1 VARCHAR2(10) NOT NULL, 
... 

你的PK是錯誤的,以及,你不「T有一個名爲只是HOHCode柱:

CONSTRAINT pk_tblParentMaster_HOHCode PRIMARY KEY (HOHCodeId), 

所以:

CREATE TABLE tblParentMaster 
    (HOHCodeid VARCHAR2(10), 
    Parent1 VARCHAR2(10), 
    Address VARCHAR2(30), 
    Home_Phone_Number CHAR(10), 
    Address1 VARCHAR2(30), 
    City VARCHAR2(20), 
    States CHAR(2), 
    Zip CHAR(5), 
    Parent2Code VARCHAR2(10), 
    Parent2 VARCHAR2(10), 
    Address2 VARCHAR2(30), 
    Volunteer CHAR(1) DEFAULT 'N', 
    Email VARCHAR2(20), 
     CONSTRAINT pk_tblParentMaster_HOHCode PRIMARY KEY (HOHCodeId), 
     CONSTRAINT nn_tblParentMaster_Parent1 CHECK (Parent1 is NOT NULL), 
     CONSTRAINT ck_tblParentMaster_Volunteer CHECK (Volunteer IN ('Y', 'N')) 
); 

table TBLPARENTMASTER created.