我有以下SQL代码:
CREATE TABLE staff(
SID NUMBER(20) PRIMARY KEY,
STAFF_NAME VARCHAR2(50) NOT NULL,
DESIGNATION VARCHAR2(30) DEFAULT 'ASSISTANT PROFESSOR',
GENDER CHAR NOT NULL,
DOB DATE,
DOJ DATE DEFAULT SYSDATE,
SALARY NUMBER(7,2),
MOBILE NUMBER(10) NOT NULL,
EMAIL VARCHAR2(20),
PRESENT_ADDRESS VARCHAR2(70),
EXPERIENCE NUMBER(1,1),
DEPT_ID VARCHAR2(2) FOREIGN KEY REFERENCES DEPT(DEPT_ID)
)
/
但我得到了这个输出:
DEPT_ID VARCHAR2(2)FOREIGN KEY REFERENCES DEPT(DEPT_ID) * 第13行的错误: ORA-00907:缺少右括号
导致问题的原因是什么?
答案 0 :(得分:1)
不是:
CREATE TABLE staff (
SID NUMBER(20) PRIMARY KEY
,STAFF_NAME VARCHAR2(50) NOT NULL
,DESIGNATION VARCHAR2(30) DEFAULT 'ASSISTANT PROFESSOR'
,GENDER CHAR NOT NULL
,DOB DATE
,DOJ DATE DEFAULT SYSDATE
,SALARY NUMBER(7, 2)
,MOBILE NUMBER(10) NOT NULL
,EMAIL VARCHAR2(20)
,PRESENT_ADDRESS VARCHAR2(70)
,EXPERIENCE NUMBER(1, 1)
,DEPT_ID VARCHAR2(2)
,FOREIGN KEY (DEPT_ID) REFERENCES DEPT(DEPT_ID)
)
在[FOREIGN KEY]和[REFERENCES]
之间查看