当前位置:网站首页>MySQL - CRUD operations
MySQL - CRUD operations
2022-08-02 02:12:00 【Xiaolock830】
增
That is, a new row is added to the selected table in the database
全部插入
insert into 表名 values(值1,值2 ...);
Insert selected columns
insert into 表名(指定列名1, 指定列名2...) values(值1, 值2...);
删
That is, delete a row from the selected table in the database
delete from 表名;
我们可以用whereKeywords to filter the condition of the column we want to delete
delete from 表名 where 条件;
需要注意的是,在MySQL中,Our logical operator sumJava与CLanguage is different,Some common situations are listed below.
操作符含义
| 运算符 | 含义 |
|---|---|
| > ,>=,<,<= | Consistent with normal logic |
| = | 和C语言不同,MySQLIn the judgment of equality, use single equals |
| <=> | Determine whether both sides arenull,都为null返回true |
| !=, <> | 不等于 |
| between a and b | 判断是否在>= a , <= b的范围内 |
| in(a , b, c…) | 判断是否为a,b,c中的一个 |
| is null | 判断是否为null,是则返回ture |
| is not null | 判断是否为null,是则返回false |
| like | 模糊查询,%表示·多个字符,_表示单个字符 |
| and | 相当于&& |
| or | 相当于|| |
| not | 相当于~ |
查
select 查询范围 form 表名;
We can use it in the query scope position*,It means that we want to query all the data
select * form 表名;
同样的,我们也可以用whereto filter our query criteria
select * form 表名 where 筛选条件;
去重
我们可以用distinctkeyword to deduplicate the query results
select distinct 查询范围 from 表名;
排序
我们可以用order by关键字来对查询结果进行排序
升序
select 查询范围 from 表名 order by asc;
降序
select 查询范围 from 表名 order by desc;
别名
We can alias query results
select header expression 别名 from 表名;
分页
When our query data volume is too large,We can query page by page like a browser
使用关键字limit
select * from 表名 limit Limit the number of displays;
我们用offset进行翻页,The default first page offset is 0
select * from 表命 limit Limit the number of displays offset 偏移量;
改
update 表名 set 表头 = 表达式 where 条件;
需要注意的是,Our data operations are very dangerous,一定要小心谨慎
边栏推荐
- AntPathMatcher使用
- Fly propeller power space future PIE - Engine Engine build earth science
- AWR analysis report questions for help: How can SQL be optimized from what aspects?
- oracle查询扫描全表和走索引
- Yunhe Enmo: Let the value of the commercial database era continue to prosper in the openGauss ecosystem
- Power button 1374. Generate each character string is an odd number
- 哈希冲突和一致性哈希
- ¶ Backtop back to the top is not effective
- Day115.尚医通:后台用户管理:用户锁定解锁、详情、认证列表审批
- Force buckle, 752-open turntable lock
猜你喜欢
随机推荐
Yunhe Enmo: Let the value of the commercial database era continue to prosper in the openGauss ecosystem
Fly propeller power space future PIE - Engine Engine build earth science
Redis for distributed applications in Golang
【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
libcurl访问url保存为文件的简单示例
LeetCode brushing diary: 33. Search and rotate sorted array
Speed up your programs with bitwise operations
Golang分布式应用之定时任务
2022-07-30 mysql8执行慢SQL-Q17分析
Personal blog system project test
搜罗汇总的效应
LeetCode brushing diary: 53, the largest sub-array and
Redis Persistence - RDB and AOF
6-25 Vulnerability Exploitation - irc Backdoor Exploitation
A good book for newcomers to the workplace
NIO‘s Sword(牛客多校赛)
Typescript31 - any type
LeetCode Review Diary: 34. Find the first and last position of an element in a sorted array
哈希冲突和一致性哈希
[LeetCode Daily Question]——654. The largest binary tree








