1.添加字段:
alter table add 字段名 first | after 字段名;
2.插入数据(不指定字段名):
insert into 表名 values (值1,值2,……);
3.为指定字段插入数据:
insert into 表名(字段1,字段2.……)values(值1,值2,……;
4.拓展:
insert into 表名 set 字段1=值1,字段2=值2……;
5.补充:
设置自动增长:out_increment
设置字体格式:set names gb2312
1.删除指定数据:
delete from 表名 where 字段=*;
delete from 表名;
注:truncate 也可以删除数据,但是它只能删除所有数据,原理为删除原来的表再新建一张表。
1.更新部分数据:
update 表名 set 字段1=值1,字段2=值2,…… where 字段=*(字段<*);
update 表名 set 字段1=值1,字段2=值2……;
(1)简单查询
1.查询指定字段:
select 字段1,字段2……from 表名;
select 字段1,字段2,…… from 表名 order by 字段 asc(默认)|desc;
select distinct 字段1,字段2,…… from 表名;
select * from 表名;
select * from 表名 where 条件;
select * from 表名 where 字段 [not] in (元素1,元素2,……)
select * from 表名 where 字段 [not] between 值1 and 值2;
select 字段1,字段2,……from 表名 where 字段 is [not] null,
select 字段1,字段2,……from 表名 where 字段名 [not] like '匹配字符串';
select * from 表名 group by 字段名;
select * from 表名 order by 字段名 desc limit *(从第*位开始查询),*(返回*条记录);
select * from 表名 where name like "s%";
select * from 表名 where name like "%g";
select * from 表名 where 条件表达式1 and 条件表达式2 and……;
select * from 表名 where 条件表达式1 or 条件表达式2;