android 添加外键时外键存在语法错误

mgdq6dx1  于 2022-12-02  发布在  Android
关注(0)|答案(1)|浏览(117)

使用alter和add语句时出现错误
SQL代码为:

create table lecturer (

    lecturer_id int primary key,

    lecturer_name varchar(20)

    )
create table course_lecturer(

          date varchar(20)

      )
alter table course_lecturer

add foreign key(lecturer_id) references lecturer(lecturer_id)

错误可归结为:
“外键”附近:语法错误
我要链接讲师表和课程_讲师

b4wnujal

b4wnujal1#

create table lecturer (
    lecturer_id int primary key,
    lecturer_name varchar(20)
    )

create table course_lecturer(
          //U need here a lecturer_id for bind the fk 
          date varchar(20)
      )
alter table course_lecturer

add foreign key(lecturer_id) references lecturer(lecturer_id)

希望这能有所帮助!

相关问题