flush privileges;
例如:
create database 數(shù)據(jù)庫名;
grant all privileges on 數(shù)據(jù)庫名.* to 某個用戶名@'%' identified by '密碼';
flush privileges;
7、插入一條語句的語法
insert into 表名 values(字段1,字段2……)
例如:
添加全部的數(shù)據(jù):
insert into user values(1,'name',23);
添加指定某個字段的數(shù)據(jù):
insert into user(name,age) values('name',12);
8、更新一條數(shù)據(jù)的語法
update 表名 set 要修改的字段=修改的內(nèi)容 where 字段=值
例如:
修改指定的數(shù)據(jù):
update user set name='wewe' where id=1;
修改全部的數(shù)據(jù):
update user set name='wewe';
9、刪除一條的語句
delete from 表名 where 字段=值
例如:
刪除全部的數(shù)據(jù):
delete from user;
刪除指定的某個數(shù)據(jù):
delete from user where id=1;
10、查詢一張表的語句
select * from 表名 where 字段=值;
例如:
查詢?nèi)康臄?shù)據(jù):
select * from user;
查詢符合某個字段的信息:
select * from user where id=1;
查詢指定字段的數(shù)據(jù):
select name,age from user;
11、排序的語法
order by xxx desc/asc
例如:
如果不指定順序,默認為升序:
select * from user order by id;
降序:
select * from user order by id desc;
升序:
select * from user order by id asc;
12、降序是什么
降序是desc
例如:
select * from user order by id desc;
13、聚合函數(shù)有哪些
求和: sum()
求數(shù)量:count()
求平均:avg()
例如:
求數(shù)量:
select COUNT(category_id) from tb_content;
求和:
select SUM(category_id) from tb_content;
求平均:
select AVG(category_id) from tb_content;
14、聚合語法是什么,也就是分組語法
select 列1,列2……,sum(字段) from 表名 group by 列1,列2…… having sum(字段) > 某個數(shù)量;
15、分組語法謹記一個點是什么
不是聚合函數(shù)的字段要出現(xiàn)在group by 后面
16、分組語法有個取多少行的語法是什么?比如工資和大于5000
limit
例如:
select id from tb_content group by id having sum(money) > 5000 LIMIT 2;