1、新建一个数据库 handsome
create table handsome(name char(10),age decimal,sex char(6) default ‘male’);
create table students like handsome;
2、设置主键
alter table handsome add primary key(name);
3、插入数据
INSERT INTO handsome(NAME,age) VALUES('宋仲基',30);
INSERT INTO handsome(NAME,age) VALUES('吴亦凡',28);
INSERT INTO handsome(NAME,age) VALUES('白敬亭',22);
INSERT INTO handsome(NAME,age) VALUES('王俊凯',18);
INSERT INTO handsome(NAME,age) VALUES('刘昊然',19);
INSERT INTO handsome(NAME,age) VALUES('马天宇',30);
4、查询
SELECT * FROM handsome WHERE NAME = '宋仲基';
SELECT * FROM handsome WHERE NAME like '%宋%';
SELECT AVG(age) FROM handsome ;
5、增加一列
ALTER TABLE handsome ADD COLUMN Height INT;
6、删除
DELETE from table handsome where name like '白%';
DROP TABLE students;