Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在mysql中创建关联实体_Mysql_Associative Table - Fatal编程技术网

在mysql中创建关联实体

在mysql中创建关联实体,mysql,associative-table,Mysql,Associative Table,我试图通过关联实体LINEITEM组合这两个表,当我试图在代码中设置主键和外键时,它总是给我错误。任何帮助都将不胜感激。谢谢 Database changed mysql> select * from STUDENT; +---------+--------+-----+ | SFName | SLName | SID | +---------+--------+-----+ | Geno | Smith | 1 | | Kevin | White | 2 | | Tav

我试图通过关联实体LINEITEM组合这两个表,当我试图在代码中设置主键和外键时,它总是给我错误。任何帮助都将不胜感激。谢谢

Database changed mysql> select * from STUDENT; +---------+--------+-----+ | SFName | SLName | SID | +---------+--------+-----+ | Geno | Smith | 1 | | Kevin | White | 2 | | Tavon | Austin | 3 | | Charles | Sims | 4 | | Mario | Alford | 5 | +---------+--------+-----+ 5 rows in set (0.00 sec) mysql> select * from ASSIGNMENT; +------------------+-------+ | AName | AType | +------------------+-------+ | Final Exam | T | | Formal Report | H | | Grammar Exercise | H | | Informal Report | H | | Midterm | T | | Resume | H | +------------------+-------+ 6 rows in set (0.00 sec)
mysql>

VARCHAR需要一个长度。请看,如果您提供错误消息会有所帮助。这很有效,我感谢您的帮助!
create table LINEITEM
( SID int
, AName varchar
, LIGrade decimal(5,2)
, primary key(SID, AName)
, foreign key (SID) references STUDENT(SID)
, foreign key (AName) references ASSIGNMENT(AName)
);
ERROR 1064 (42000): You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version for the right syntax to use near 
' LIGrade decimal(5,2), primary key(SID, AName), foreign key (SID) references STU' at line 1