当前位置:网站首页>MySQL_ Addition, deletion and modification of data processing
MySQL_ Addition, deletion and modification of data processing
2022-06-22 12:44:00 【YHSevenWater】
The addition, deletion and modification of data processing can be learned in the following steps :
• Use DML sentence
• insert data
• Update data
• Delete data
(1)DML( Data manipulation language )
• DML(Data Manipulation Language – Data manipulation language ) Can be performed under the following conditions :
– Insert data into table
– Modify existing data
– Delete existing data
• A transaction is a process in which several tasks are performed DML The sentences make up
(2) insert data
INSERT Sentence syntax
• Use INSERT Statement inserts data into a table
INSERT INTO `user`(id,name,salary)
VALUES (9,' Xiao Luo ',7920);


• Using this syntax, you can only insert into a table at a time One data
• Character and date data should be enclosed in single quotes
INSERT INTO `user`(id,name,salary,hire_date)
VALUES (10,' Thank you ',5920,'2019-3-21');


Insert null values into the table
• Implicit mode : Omit the value of the column in the column name table
INSERT INTO `user`(id,name)
VALUES (11,' Xiaofen ');


• Display mode :: stay VALUES Clause to specify a null value
INSERT INTO `user`
VALUES (12,' Trabecula ',NULL,NULL);


Inserts the specified value
NOW() function : Record the date and time of the current system
INSERT INTO `user`(id,name,salary,hire_date)
VALUES (13,' Little thunder ',5600,NOW());


Copy data from other tables
• stay INSERT Add a subquery to the statement
• There's no need to write VALUES Clause
• The list of values in the subquery should be the same as INSERT The column name in Clause corresponds to
INSERT INTO `user`
SELECT *
FROM `student`
WHERE student_name LIKE ' Small %';



(3) Update data
UPDATE Sentence syntax
• Use UPDATE Statement update data
• You can update more than one piece of data at a time
• If you need to roll back data , It needs to be guaranteed in DML front , Set it up : SET AUTOCOMMIT = FALSE
• Use WHERE Clause specifies the data to be updated
UPDATE `user`
SET id = 14
WHERE id = 18;


• If omitted WHERE Clause , Then all data in the table will be updated
UPDATE `user`
SET hire_date = '2021-8-24';


(4) Delete data
DELETE sentence
• Use DELETE Statement to delete data from a table
• Use WHERE Clause deletes the specified record
DELETE FROM `user`
WHERE id = 8;


• If omitted WHERE Clause , All data in the table will be deleted
DELETE FROM `student`;


| sentence | function |
|---|---|
| INSERT | Insert |
| UPDATE | to update |
| DELETE | Delete |
边栏推荐
- CVPR 2022 | 针对场景文本检测的视觉语言模型预训练
- 第十一届 蓝桥杯 嵌入式设计与开发项目 决赛
- 函数指针和指针函数的区别
- Flutter動畫入門: 內外逆向環Loading動畫
- Flutter imitates airbnb's price range filter. (I)
- 帝云CMS升级PHP8注意事项
- 胡润研究院首发中国元宇宙潜力企业榜,巨杉数据库入选未来之星企业
- Use of ncnn (compulsory for beginners)
- Flutter:剥离StatefulWidget——简化页面开发、跳转以及传值
- OpenCV调用usb摄像头出现“select timeout”解决方法
猜你喜欢

Flutter——实现网易云音乐的渐进式卡片切换

Repair flutter_ webview_ The problem of web layer residue when the plugin slides out of the page

Flutter動畫入門: 內外逆向環Loading動畫

关于 GIN 的路由树

TIS教程01-安装

MySQL_创建和管理表

Small demo of QT page layout class

Final of the 12th Blue Bridge Cup embedded design and development project

推荐一款M1芯片电脑快速搭建集群的虚拟机软件

Flutter mixed development exercise - large picture of collaborative loading of ever & method channel
随机推荐
About buildreoot compilation -- the function is configured but not compiled into the kernel
0179 largest number
Fast establishment of tensorflow2 model optimization environment
Latex Greek alphabet
Flutter混合开发练习——Evenet&Method Channel协作加载大图
智龄语音+php
1961 check if string is a prefix of array
When the tiflash function is pushed down, it must be known that it will become a tiflash contributor in ten minutes
Parallels Desktop 17.1.4pd虚拟机
[MySQL] the difference between where and having
DevSecOps: CI/CD 流水线安全的最佳实践
C language itoa() function and atoi() function explanation (integer to character c implementation)
在C#开发中使用第三方组件LambdaParser、DynamicExpresso、Z.Expressions,实现动态解析/求值字符串表达式
SAP-ABAP-BAPI_GOODSMVT_CREATE创建物料凭证bapi的各种情况如何赋值
Sap-abap- how to call an external interface by webapi
Help financial informatization innovation, Jushan database has won more than 50 financial customers recently
客户成员价值分析
ES aggregation详解
Zcu102 PL end running water lamp
SAP-ABAP-SE14丢失的数据如何恢复