是一个数据库(存储数据的仓库) 可以存储的内容有 文字 图片 音效等等
DDL 数据库操作语言 对数据库的操作 create(添加数据库) alter(修改数据库) drop (删除数据库)
DCL 数据控制语言 对数据操作 grant、revok
DQL 数据查询语言 对数据操作 查询 select(查询)
DML 数据操作语言 对数据操作增改删 insert(添加数据) update(修改数据) delete(删除数据)
char类型是固定字节数
varcahr类型是可以改变字节数
create database 数据库名
alter database 数据库名 CHARSET = UTF8
rename database 源数据库名 to 更改后数据库名
show databases
drop database 数据库名
create table users (
userid int,
username VARCHAR(20),
useraddress varchar(20),
userphone varchar(20)
)
// 添加单条数据
// 举例
insert into 表格名 (userid,username,useraddress,userphone) VALUES (1,'张三','北京海淀','11110')
// 添加多条数据
//举例
insert into 表格名 values(1,'张1','北京海淀4','111'),(2,'张2','北京海淀2','2222'),(3,'张3','北京海淀3','333333')
// 修改所有数据
update 表格名 set 要修改对象 ='胃不是吧'
// 修改单条数据
update 表格名 set 要修改对象 ="脉动" where 参照对象 = 3
// 删除单条数据
delete from 表格名 where 删除参照对象 =
// 删除多条/区间
delete from 表格名 where 删除参照对象 >=4 and userid<=6 // 比如这个删除的是id大于4且小于6之间的
// 全部删除
delete from 表格名
show tables
show create table 表格名
alert table 表格名 add 修改对象 char(2)
select * from 表格名
select * from 表格名
select * from 表格名 where 查询对象 = **
select * from 表格名 where 查询对象>=30 and score <=80 // and 查询年龄在大于30小于50的数据
select * from 表格名 where 查询对象 between 50 and 80 // and 查询年龄在大于30小于50的数据
select * from 表格名 where 查询对象 in (50,80) // in 查询年龄在80岁的数据
select * from 表格名 where 查询对象= '男' or gender = '女' // OR 查询性别男和女的第一次出现数据
select * from 表格名 ORDER BY 查询对象 asc // 升序
select * from 表格名 ORDER BY 查询对象 desc // 降序
select count(*) from 表格名 GROUP BY 查询对象 // 用于算总数 以及 对数据进行分页 总的数据数
select MAX(查询对象) FROM 表格名 // 找最大的数
select Min(查询对象) FROM 表格名 // 找最小的数
select sum(查询对象) FROM 表格名 // 求和
select avg(查询对象) FROM 表格名 // 平均数(返回结果浮点数)
select * from 表格名 where 查询对象 like '%明%' // 搜索名字里全部带明的
select * from 表格名 where 查询对象 like '%明' // 搜索名字里叫明的
select * from 表格名 where 查询对象 like '明%' // 搜索名字里姓名的
select * from 表格名 where 查询对象 like '明_' //_代表占一个字符 搜索结果为明** 列如明刚
select * from 表格名 where 查询对象 like '_明' // 搜索结果为**明 列如 小明
select * from 表格名 where 查询对象 like '__明_' // 搜索结果为*明* 例如王明珂
本文地址:https://blog.csdn.net/best_decision/article/details/107324020
如对本文有疑问, 点击进行留言回复!!
一步步教你用Prometheus搭建实时监控系统系列(一)——上帝之火,普罗米修斯的崛起
网友评论