1.查看当前编码

show variables like '%char%'

2.修改user表中id=1的name 为 A  where后面是条件,就是定位

update  user  set  name='A'  where  id=5

3.符号

> //大于符号    <  //小于符号     <>  //不等于符号    in()  //在什么里面    between  //在什么之间     and  //和     or  //或

4.从user表中删除id=5的字段

delete  from  user   where  id=5

5.刷新权限

flush  privileges

6.修改root的密码为admin

USE mysql  UPDATE user  SET   password=PASSWORD('admin')  WHERE user='root' 

7.创建一个test用户,密码123456,登陆ip为127.0.0.1

CREATE   user  'test'@'127.0.0.1'  identified  by  '' 

8.分配权限

grant  权限1,权限2.... on 数据库名.*  to  用户名@ip或%
grant update,insert,delete on shop.* to 'huazai'@'127.0.0.1'

9.撤销huazai对shop表 的select 权限

revoke  select  on   shop.*  from  'huazai'@'127.0.0.1'

10.

所有的数据库 就用*.*   所有的权限就用ALL或者ALL PRIVILEGES

11.查看huazai用户权限

show  grants  for  'huazai'@'127.0.0.1' 

12.创建用户和授权一起的语句

grant  select,delete(权限)   on  shop(数据库).*  to  'test'@'127.0.0.1'  identified  by  'test'

13.删除用户test

drop  user    'test'@'127.0.0.1' 

14.清空user的数据

 truncate   user

15.从user表中过滤重复的password出来

select  distinct   password  from  user 

16.模糊查询,从user表中查user_name字段是huazai的所有数据

select  *  from  user   where  user_name  like  'huazai'

17.模糊匹配查询,只要user_name的最后是ai都会查出来 ,这里的%相当于python的*

数据小于10万可以用like,不然查询有点慢,数据比较大可以用Sphinx(斯芬克司)

select   *  from  user  where   user_name    like  '%ai'

18.排序

 select  *  from  表名   order  by  字段名  asc(升序 默认  可以不加)
select * from 表名 order by 字段名 desc 降序

19.聚合函数

select   count(*)  from   表名    查询表的记录数
select sum(列名)from 表名 查询此列的和
select avg(列名) from 表名 查询此列的平均值
select max(列名) from 表名 查询此列的最大值
select min(列名) from 表名 查询此列的最小值

20.分组查询

select   *   from  表名   group  by sex  按照性别分组
select * from 表名 group by sex having count(*)>3

最新文章

  1. C#Linq技术中SelectMany(...)的内部实现推测
  2. Linux(五)__硬盘分区
  3. oracle报错:ORA-28000: the account is locked
  4. 在C#中使用C++编写的类
  5. WEB版一次选择多个文件进行批量上传(Plupload)的解决方案
  6. 垂直居中,水平居中html例子
  7. 由window.history.back()引发的问题
  8. Lua 的数据结构
  9. android ViewPager滑动事件讲解
  10. maven 配置报错 JAVA_HOME not found in your environment
  11. Fiddler 跟踪 手机页面数据包
  12. codeforces 546E. Soldier and Traveling 网络流
  13. 2014-10-30NOIP复习题1
  14. 利用Swashbuckle生成Web API Help Pages
  15. MySQL 8.0.11安装配置
  16. shell脚本 统计一段程序运行时间【转】
  17. /usr/bin/uwsgi --http :8888 --wsgi-file wsgi.py --master --processes 4 --threads 2
  18. Springboot 允许跨域访问
  19. PXC备份方式总结
  20. C#泛型的抗变与协变

热门文章

  1. VS2010-MFC(字体和文本输出:CFont字体类)
  2. python的__file__和__name__变量
  3. &lt;day006&gt;bootstrap的简单学习 + 轮播图
  4. c#使用打印机
  5. iOS逆向系列-脱壳
  6. 2019-9-23-asp-dotnet-core-3.0-接口返回-json-使用-PascalCase-格式
  7. Nand flash 芯片工作原理
  8. jvisualvm图解【转】
  9. Python的字符串修改报错:TypeError: &#39;str&#39; object does not support item assignment
  10. Flink Checkpoint 问题排查实用指南