请帮我这个代码。我尝试创建一个表,但它不断弹出错误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'))
);
答案 0 :(得分:1)
这不是你如何声明一个非空约束。您可以将命名约束设为shown in the documentation:
...
Parent1 VARCHAR2(10),
...
CONSTRAINT nn_tblParentMaster_Parent1 CHECK (Parent1 is NOT NULL)
...
或者将其声明为内联,其名称不会很好:
...
Parent1 VARCHAR2(10) NOT NULL,
...
您的PK也是错误的,您没有名为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.