1、增:
insert into 表名(字段名1,字段名2,...) values(值1,值2,...):
insert into 表名 values(值1,值2,...):
insert into 表名(): 括号内不指定自增字段\默认字段相应字段也会取得值
alert table stu_info add(addr char(50));
2、删:
delete from 表名
where 筛选条件;(例:字段名=1/num=1) 删除一行
truncate 不可恢复性删除
drop 直接删除表
3、改:
update 表名 set 字段名1=新值1,字段名2=新值2... where 筛选条件;
select name as sname,phone as phone_num from stu_info;
select * from stu_info order by chinese asc/desc; 语文成绩列按照升序/降序排列
select num,sname,math,chinese,math+chinese as zong from stu_info order by zong desc;
将数学列和语文列成绩相加新建总分列,并且按降序排列
4、查:
select 字段名1,字段名2... from 表名 筛选显示两列数据
select * from stu_info limit 0,1; 从第0行开始显示一行(第0行就是第一行)
select * from stu_info where gender='M'; 筛选性别为男的数据
select * from stu_info where name like '%赵'; 筛选出名字为~赵 的人
select * from stu_info where name like '赵%'; 筛选出姓赵的人的数据
select * from stu_info where name not like '赵%'; 筛选出不姓赵的人
select * from stu_info where gender='M' limit 0,2; 性别为男的人显示前两行数据