mysql 外來鍵遇到的一點小錯誤

2021-06-22 05:08:47 字數 1125 閱讀 9583

由於c#的作業,又要折騰一下mysql,在寫外來鍵的時候出現了一些小小的問題,記錄一下:

1.沒有問題的 sql 語句

create database student_grades_db ;

use student_grades_db;

create table student (

id int primary key,

name varchar(45) not null,

gender varchar(10) not null

);create table course (

id int primary key auto_increment,

name varchar(45) unique not null

) auto_increment=100;

2.出問題的地方:

create table grade (

stu_id int,

course_id int,

grade int not null,

primary key (stu_id, course_id),

constraint 'stu_id_fk' foreign key ('stu_id') references 'student' ('id'),

constraint 'course_id_fk' foreign key ('course_id') references 'course' ('id')

);

然後在這句上面

constraint 'stu_id_fk' foreign key ('stu_id') references 'student' ('id'),

一直報錯

修改:把引號除去,就沒有問題了

constraint stu_id_fk foreign key (stu_id) references student (id),

constraint course_id_fk foreign key (course_id) references course (id)

平時遇到的小錯誤

1.post的方法必須夾 responsebody否則404 2.combobox子頁面的id不能一樣,name可以一樣否則不顯示載入錯誤,easy ui的標籤都差不多,千萬id不能一樣象form表單之類的要不然出大錯 資料就混亂了所以乙個子頁面要有乙個的名字 3.url傳值 url basepat...

egit的乙個小錯誤

用egit和堅果雲搭配開發環境,配置egit時提示乙個錯誤 the current branch is not configured for pull.no value for key branch.master.merge found in configuration google一番後發現原來是...

ntp的乙個小錯誤

root localhost ntpdate 10.128.14.25 3 apr 21 05 05 ntpdate 1506 the ntp socket is in use,exiting 收到此錯誤訊息的原因是由於 xntpd 已經繫結到了該 socket。執行 ntpdate 時,它會首先進...