1.主键设置在中间,在末尾都可以,例如:
mysql> CREATE TABLE example4 (
stu_id integer,
grade float,
stu_name varchar(100),
primary key(stu_id,stu_name),
favourite text );
Query OK, 0 rows affected (0.02 sec)
2.varchar 类型必须指明长度,否则会报错,例如:
CREATE TABLE example3
(
stu_id int,
grade float,
stu_name varchar,
favourite text,
primary key(stu_id,stu_name)
);
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 ', favourite text,primary key(stu_id,stu_name))' at line 1
3.