1.创建表
create table user(
userId varchar(3) not null,
name varchar(5),
ename varchar(10),
primary key(userId)
);
2.删除表
drop table if exists user;
3.插入数据
insert into user(userId,name,ename)values('101','晓晓','tom');
4修改数据
update user set name='小',ename='xiao' where userId='101';
5删除数据
delete from user where name='晓晓';
6查询数据
select * from user
select name from user
select name 姓名 from user
select distinct name from user
select * from user where age=20
select * from user where city !='北京'
select * from user where age>20
select * from user where age>=20
select * from user where city in('北京','上海')
select * from user where city not in('北京','上海')
select * from user where age between 10 and 20
select * from user where age not between 10 and 20
select * from user where name like '晓%'
select * from user where name like '晓_'
select * from user where name not like '晓%'
select * from user where ename like binary 'T%'
select * from user where ename rlike '[0-9]'
select * from user where ename not rlike '[0-9]'
select * from user where ename is null
select * from user where ename is not null
select * from user where age=20 and city='北京'
select * from user where city='北京'or city='上海'
select * from user where not city='北京'
select * from user order by age
select * from user group by city;
select city,count(userId) from user group by city having count(userId)>1
select city,min(age),max(age),sum(age),avg(age),count(age),group_concat(name) from user where sex='男'group by city having avg(age)>20 order by min(age)
select age,age/2 from user
查询3条数据
select * from user limit 3
(从第几条开始,查询几条)查询4-6三条数据
select * from user limit 3,3