2016-10-06 5 views
0

외래 키가있는 테이블을 만들지 못합니까? 이 테이블을 만들려고하고 어떤 이유로 든 작동하지 않습니다. 오류 메시지가 계속 나타납니다.외래 키가있는 테이블을 만들지 못합니까?

내 코드는 다음과 같습니다

create table lecturers (
    lectid int not null, 
    fname varchar(34), 
    lname varchar(34), 
    unitid int, 
    primary key (lectid), 
    constraint unitFK foreign key (unitid) references units(unitid); 

다른 테이블 :

mysql> create table units 
(unitid int primary key, 
unit_name varchar(34)); 
Query OK, 0 rows affected (0.04 sec) 

답변

0

는 괄호에 강사 테이블에 대해 CREATE TABLE 문이없는과 외래 키 작동

create table lecturers (
    lectid int not null, 
    fname varchar(34), 
    lname varchar(34), 
    unitid int, 
    primary key (lectid), 
    constraint unitFK foreign key (unitid) references units(unitid)); 
시도
관련 문제