mysql基本笔记之二
2024-10-07 23:25:01
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
最新文章
- C#Linq技术中SelectMany(...)的内部实现推测
- Linux(五)__硬盘分区
- oracle报错:ORA-28000: the account is locked
- 在C#中使用C++编写的类
- WEB版一次选择多个文件进行批量上传(Plupload)的解决方案
- 垂直居中,水平居中html例子
- 由window.history.back()引发的问题
- Lua 的数据结构
- android ViewPager滑动事件讲解
- maven 配置报错 JAVA_HOME not found in your environment
- Fiddler 跟踪 手机页面数据包
- codeforces 546E. Soldier and Traveling 网络流
- 2014-10-30NOIP复习题1
- 利用Swashbuckle生成Web API Help Pages
- MySQL 8.0.11安装配置
- shell脚本 统计一段程序运行时间【转】
- /usr/bin/uwsgi --http :8888 --wsgi-file wsgi.py --master --processes 4 --threads 2
- Springboot 允许跨域访问
- PXC备份方式总结
- C#泛型的抗变与协变
热门文章
- VS2010-MFC(字体和文本输出:CFont字体类)
- python的__file__和__name__变量
- <;day006>;bootstrap的简单学习 + 轮播图
- c#使用打印机
- iOS逆向系列-脱壳
- 2019-9-23-asp-dotnet-core-3.0-接口返回-json-使用-PascalCase-格式
- Nand flash 芯片工作原理
- jvisualvm图解【转】
- Python的字符串修改报错:TypeError: &#39;str&#39; object does not support item assignment
- Flink Checkpoint 问题排查实用指南