当前位置:网站首页>MySQL DML (data manipulation language)
MySQL DML (data manipulation language)
2022-07-18 14:03:00 【Caught in a rain】
| The notebook |
One 、 Insert statement
Grammar 1 :
INSERT INTO Table name ( Name ,...) VALUES( value 1,...);
There are certain requirements for using this statement :
The type of the inserted value should be consistent with or compatible with the type of the column ;
The number and order of fields are not necessarily the same as those in the original table , However, you must ensure that the values and fields correspond one by one ;
Not for NULL The column of must have a value inserted ; The order of the columns can be changed ;
The number of columns and the number of values must be the same ;
You can omit column names , The default is all columns , And the order of the columns is the same as that of the tables .
eg:
INSERT INTO beauty(id,NAME,sex,borndate,phone,photo,boyfriend_id)
VALUES(1,' Liu Yifei ',' Woman ','1987-8-25','12345678910',NULL,2);
Grammar II :
INSERT INTO Table name
SET Name = value , Name = value ,...
Their differences :
① Syntax 1 supports inserting multiple lines , But syntax 2 is not supported
INSERT INTO beauty(id,NAME,sex,borndate,phone,photo,boyfriend_id)
VALUES(1,' Liu Yifei ',' Woman ','1987-8-25','12345678910',NULL,2),
(1,' Liu Yifei ',' Woman ','1987-8-25','12345678910',NULL,2),
(1,' Liu Yifei ',' Woman ','1987-8-25','12345678910',NULL,2);
② Syntax 1 supports subqueries , Syntax 2 does not support
INSERT INTO beauty(id,NAME,phone)
SELECT id,boyname,'123456' FROM boys WHERE id<3;
Two 、 Modify the statement
UPDATE Table name
SET Column = The new value , Column = The new value ,...
WHERE filter
eg:
UPDATE beauty SET phone='12345678' WHERE NAME LIKE ' The tang dynasty %';
3、 ... and 、 Delete statements
Mode one :DELETE
1、 Delete single table
DELETE FROM Table name WHERE filter
2、 Delete multiple tables
sql92 grammar :
DELETE surface 1 Another name for , surface 2 Another name for
FROM surface 1 Alias , surface 2 Alias
WHERE Connection condition AND filter ;
sql99 grammar :
DELETE surface 1 Another name for , surface 2 Another name for
FROM surface 1 Alias
INNER|LEFT|RIGHT JOIN surface 2 Alias ON Connection condition
WHERE filter ;
Case study : Delete Zhang Wuji's girlfriend's information
DELETE b
FROM beauty b INNER JOIN boys bo
ON b.`boyfriend_id`=bo.`id`
WHERE bo.`boyName`=' zhang wuji ';
Mode two :TRUNCATE
grammar :
TRUNCATE TABLE Table name ;
The difference between the two ways :
①DELETE You can add WHERE Conditions ,TRUNCATE Cannot add
②TRUNCATE More efficient
③ Suppose the table to be deleted has a self growing column ,
If you use delect After deleting , Then insert the data , Starting from the value breakpoint of the growth column ,
and TRUNCATE After deleting , Then insert the data , The value of the self growing column starts from 1 Start .
④TRUNCATE Delete has no return value ,delect Delete with return value
⑤TRUNCATE Deletion cannot be rolled back ,delect Delete can be rolled back
| notebook |
边栏推荐
- PhpMyAdmin 4.8.1 remote file contains vulnerability [gwctf 2019] I have a database
- College personnel management system based on jsp+servlet
- Solution -- Exploration
- 关系图/族谱
- Dwelling apartment rental system based on jsp+servlet
- 騰訊員工發帖找對象,錶示偏愛程序員!評論火了......丨黑馬頭條
- 矩形排序。。。。
- T100自定义应用使用说明(azzi650)
- ES2022 Array.at( )
- marginalization
猜你喜欢

【品牌专场】跨越 X 突破,音视频聚力新机遇

二叉树,遍历

T100 user defined application instructions (azzi650)

160_ Skills_ Power Bi new function - calculate working days
![[phase locked loop] design and Simulation of all digital phase locked loop based on MATLAB](/img/3c/9fe4aec90506cef4bf0a639366263d.png)
[phase locked loop] design and Simulation of all digital phase locked loop based on MATLAB

Cultural tourism night tour project helps the development of night economy

Matlab机械臂建模运动学仿真+轨迹规划

Color supplement of MATLAB scientific research drawing (special part 6) - 336 traditional French colors
![preg_ Replace Code Execution Vulnerability [bjdctf2020]zjctf, but so](/img/e4/29e07b21593bb5ff36cb1135fa1b45.png)
preg_ Replace Code Execution Vulnerability [bjdctf2020]zjctf, but so

Golang---------小试牛刀 gin框架文件上传
随机推荐
University epidemic prevention and control system based on jsp+servlet
Interface test practice - student information management system
PageRank的原理和实现
二叉树,遍历
【锁相环】基于MATLAB的全数字锁相环设计与仿真
Automatic completion (spring daily question 58)
积分签到吸引用户的两种低成本做法
二叉搜索树BST
Quarkus practice 2: develop rest ful services to realize simple curd functions
Common and practical SQL statements
腾讯员工发帖找对象,表示偏爱程序员!评论火了......丨黑马头条
Color supplement of MATLAB scientific research drawing (special part 6) - 336 traditional French colors
Basic knowledge of triode (Part 2) ②
Workplace essentials | 123 pages Huawei internal project management ppt
Tencent employees post to find objects, indicating that they prefer programmers! Comments are hot Dark horse headlines
T100自定义应用使用说明(azzi650)
[phase locked loop] design and Simulation of all digital phase locked loop based on MATLAB
T100excel import writing template
ping 命令还能这么玩?
preg_replace 代码执行漏洞之[BJDCTF2020]ZJCTF,不过如此