2016-10-06 13 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

私は十分な評判を持っていないとしてコメント..しかし、あなたは右のデータベースエンジンを持っているかどうかを確認することはできません。 InnoDBエンジンと 外部キー作品

https://dev.mysql.com/doc/refman/5.7/en/storage-engines.html

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)); 
を試してみてくださいがあります
関連する問題