像下面那样创建TStudent表,让id、name为联合主键
create table TStudent(
id INT primary key not null,
name VARCHAR(50) primary key not null
);
会报如下错误:
Error:table "TStudent" has more than one primary key
正确的写法为如下:
create table TStudent(
id INT,
name VARCHAR(50),
primary key(id, name)
);
即联合主键,要写在建表语句最后一行,在primary key ()括号里面,且用逗号隔开。