我正在尝试使用emp_id和licence_cert_no为我的表创建一个复合主键,为什么这不起作用?
CREATE TABLE employee_licence_certificate(emp_id NUMBER(4) REFERENCES employee(emp_id)
, licence_cert_code VARCHAR2(6) REFERENCES licence_certificate(licence_cert_code)
, date_earned DATE NOT NULL)
CONSTRAINT pk_emp_licence PRIMARY KEY(emp_id, licence_cert_code)
错误消息:
Error starting at line 1 in command:
CREATE TABLE employee_licence_certificate(emp_id NUMBER(4) REFERENCES employee(emp_id)
, licence_cert_code VARCHAR2(6) REFERENCES licence_certificate(licence_cert_code)
, date_earned DATE NOT NULL)
CONSTRAINT pk_emp_licence PRIMARY KEY(emp_id, licence_cert_code)
Error at Command Line:3 Column:29
Error report:
SQL Error: ORA-00922: missing or invalid option
00922. 00000 - "missing or invalid option"
*Cause:
*Action:
答案 0 :(得分:4)
CONSTRAINT
子句需要放在括号内:
CREATE TABLE employee_licence_certificate(
emp_id NUMBER(4) REFERENCES employee(emp_id)
, licence_cert_code VARCHAR2(6) REFERENCES licence_certificate(licence_cert_code)
, date_earned DATE NOT NULL
, CONSTRAINT pk_emp_licence PRIMARY KEY(emp_id, licence_cert_code)
);