复合外键 - 在 Oracle 中可行吗?

Jat*_*ngh 2 sql database oracle

我正在尝试在 Oracle 中创建一个位于两个多对多表之间的关系/表,因此该表的主键是复合键,但两个键都是外键。

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
    ) 
PRIMARY KEY (emp_id, licence_cert_code))
Run Code Online (Sandbox Code Playgroud)

我尝试过使用组合键的方法,但似乎出现以下错误,这开始让我想知道这是否可能?

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) 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:
Run Code Online (Sandbox Code Playgroud)

cha*_*nce 5

尝试这个:

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
  ,
PRIMARY KEY (emp_id, licence_cert_code))
Run Code Online (Sandbox Code Playgroud)