mysql> create table course (id int(10), NAMES varchar(10));
Query OK, 0 rows affected (0.06 sec)mysql> create table teacher (id int(10), NAMES varchar(10));
Query OK, 0 rows affected (0.08 sec)mysql> create table stu (id int(10) primary key,
-> name varchar(20) ,
-> cid int(10),
-> tid int(10),
-> key fk_ref (cid),
-> key fk_ref1 (tid),
-> constraint cs1 foreign key(cid) references course(id),
->
-> constraint cs2 foreign key (tid) references teacher(id)
-> )
-> ;
ERROR 1005 (HY000): Can't create table '.\ww\stu.frm' (errno: 150)
为什么不能创建
!那里错误!!
Query OK, 0 rows affected (0.06 sec)mysql> create table teacher (id int(10), NAMES varchar(10));
Query OK, 0 rows affected (0.08 sec)mysql> create table stu (id int(10) primary key,
-> name varchar(20) ,
-> cid int(10),
-> tid int(10),
-> key fk_ref (cid),
-> key fk_ref1 (tid),
-> constraint cs1 foreign key(cid) references course(id),
->
-> constraint cs2 foreign key (tid) references teacher(id)
-> )
-> ;
ERROR 1005 (HY000): Can't create table '.\ww\stu.frm' (errno: 150)
为什么不能创建
!那里错误!!
Query OK, 0 rows affected (0.06 sec)mysql> create table teacher (id int(10) primary key, NAMES varchar(10));
Query OK, 0 rows affected (0.08 sec)mysql> create table stu (id int(10) primary key,
-> name varchar(20) ,
-> cid int(10),
-> tid int(10),
-> key fk_ref (cid),
-> key fk_ref1 (tid),
-> constraint cs1 foreign key(cid) references course(id),
->
-> constraint cs2 foreign key (tid) references teacher(id)
-> )
-> `id` int(10) PRIMARY KEY,
-> `name` varchar(45),
-> `title` varchar(45),
-> `pssword` varchar(45)
-> );
Query OK, 0 rows affected (0.06 sec)mysql>
mysql> CREATE TABLE `course` (
-> `id` int(10) PRIMARY KEY,
-> `name` varchar(30),
-> `` int(10),
-> `prepare` varchar(30),
-> `dep` varchar(30)
-> );
Query OK, 0 rows affected (0.06 sec)mysql> CREATE TABLE `classes` (
-> `id` int(10) PRIMARY KEY,
-> `tea_id` varchar(32),
-> `cour_id` varchar(32),
-> `room_id` varchar(32),
-> `cour_time` varchar(32),
-> KEY `fk_ref` (`tea_id`),
-> KEY `fk_ref1` (`cour_id`)
-> constraint cs1 foreign key(tea_id) references teacher(id),
-> constraint cs2 foreign key (cour_id) references course(id)
-> );
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 'const
raint cs1 foreign key(tea_id) references teacher(id),
constrain' at line 9
为什么不能创建!
和上面的哪个例子不是一样吗?