DDL(数据库定义语言)
建表
id name age
Drop talbe if esists student
create table student(
id INT PRIMARY KEY AUTO_INCREMENT,
name varchar(20) NOT NULL,
age INT NOT NULL DEFAULT 18);
添加外键约束
constraint fk_uid foreign key (字段) references 外键的表(外键表的字段)
添加联合主键约束
PRIMARY KEY (字段1,字段2)
删除表
DROP TABLE student;
修改表
增加字段(整数)
ALTER TABLE student ADD height INT;
修改字段(浮点数)
ALTER TABLE student MODIFY height DOUBLE;
修改字段(字段名,浮点数)
ALTER TABLE student CHANGE height DOUBLE;
删除字段
ALTER TABLE student DROP COLUMN height;