一、创建主键的三种方式
1、
CREATE TABLE user( uid INT PRIMARY KEY, uname VARCHAR(10), address VARCHAR(20) )
2、
CREATE TABLE user( uid INT, uname VARCHAR(10), address VARCHAR(20), PRIMARY KEY(uid) )
3、
CREATE TABLE user( uid INT, uname VARCHAR(10), address VARCHAR(20) ) ALTER TABLE user ADD PRIMARY KEY(uid);
4、联合主键
CREATE TABLE user( uid INT, uname VARCHAR(10), address VARCHAR(20), PRIMARY KEY(uid,uname) )
5、删除主键
ALTER TABLE USER DROP PRIMARY KEY;