CREATE table student(
s_id integer,
s_name varchar(100),
gender char(2),
PIN CHAR(18),
UNIQUE (PIN)
);#’指定一个候选键’
CREATE table student_BAK20230910(
s_id integer,
s_name varchar(100),
gender char(2),
PIN CHAR(18),
UNIQUE (PIN,S_ID)
);#’指定多个组合候选键’
CREATE table student_score(
s_id int,
c_id int,
score int,
primary key(c_id)
);#指定主键
CREATE table student_score( s_id int , primary key, c_id int, score int);#指定主键
CREATE table student_score_bak20230910(
s_id int,
c_id int,
score int,
primary key(c_id,s_id)
);#指定组合主键
CREATE table student_score2(
s_id int ,
c_id int,
score int,
primary key(c_id),
foreign key(s_id) references student(s_id)
);#指定外键主键 #被关联表的字段必须是主键才行
alter table student add constraint primary key(s_id); #增加主键
alter table student drop constraint primary key(s_id); #删除主键