-- 删除dropdatabase test;-- 删除数据库droptable student;-- 删除表altertable student dropcolumn age;-- 删除年龄字段(列)deletefrom student where id =3;-- 根据索引删除某一行数据(行)
7.修改
-- 修改update student set sex ="女"where id =2;-- update 表名 set 需要修改的值 where 需要修改的项
8.查询
-- 查询表select*from student;-- select 所有 from 表名select name as 姓名,sex as 性别,age as 年龄 from student;-- select 单独字段 as 汉译,...from 表名(as 可以不写)--条件查询select*from student where id=1;--模糊查询select*from student where name like'张%';
9.排序
--asc升序/desc降序select*from student orderby age asc|desc
--按性别进行分组select sex from student groupby sex;--与having组合select sex,count(*)from student groupby sex havingcount(*)>2;--分页select*from student limitstart,count
12.连接查询
--内连接select*from t1 innerjoin t2 on t1.列 = t2.列
--右连接(结果为两个表匹配到的数据,右表特有的数据,对于左表中不存在的数据使用 null 填充)select*from t1 rightjoin t2 on t1.列 = t2.列
--左连接(结果为两个表匹配到的数据,左表特有的数据,对于右表中不存在的数据使用 null 填充)select*from t1 leftjoin t2 on t1.列 = t2.列
13.联合
--union(结果无重复值)select id,name from student1 unionselect id,name from student2;--union all(结果包含重复值)select id,name from student1 unionallselect id,name from student2;