主键 primary key
外键 foreign key
非空 not null
唯一 unique
自增长 auto_increment
默认值 default
修改表名称 alter table table_name remane table_newname;
修改表中指定的字段 alter table user modify name varchar(30);
create table student(
num int(10) not null unique primary key,
name varchar(20) not null,
sex varchar(4) not null,
birthday datetime,
address varchar(50)
);
create table deparment(
d_id int(4) not null unique primary key,
d_name varchar(20) not null unique,
function varchar(50),
address varchar(50)
); create table worker(
id int (4) not null unique primary key auto_increment,
num int(10) not null unique,
d_id int(4),
name varchar(20) not null,
sex varchar(4) not null,
birthday date,
address varchar(50),
constraint worker_fk foreign key(d_id) references deparment(d_id)
);