Additional explanation, foreign keys: Do not use foreign keys, all foreign key concepts are solved at the application layer. Additional note: Database columns, that is, field names, should be prefixed with floating symbols as much as possible. The purpose of database existence: data storage and data management. Database: rows (data), columns (fields) Note: This page solves the data problem of the row. The previous page is about solving the column field problem. DML language: Data Manipulation Language 1. Add (insert) 2. Update 3. Delete 1. Add insert (add data to the row) -- Insert statement (add)
Notice: 1. The symbol above the field name is: float` 2. The symbol above the value is: single quote ' 2. Modify update 2.1 Symbols of judgment statements
2.2 Modify the value of a field, unconditionally -- Change, unconditionally. Format: UPDATE `table name` SET `field name` = value
2.3 Modify the value of a field and specify conditions -- Change, conditional. Format: UPDATE `table name` SET `field name` = value WHERE id=value1 OR id=value2
2.4 Modify the values of multiple fields and specify conditions -- Change, conditional. Format: UPDATE `table name` SET `field name 1` = 'value 1', `field name 2` = 'value 2' WHERE field name BETWEEN value 1 AND value 2
The name in the text box changes to BeiHang, and sex changes to man. 3. Delete (delete command or truncate command) 3.1 Method 1: delete command deletes all data and specified data in the table
3.2 Method 2: truncate command deletes all data in the table TRUNCATE `student`; -- The effect is to completely delete the student table 3.3 The difference between the two commands to delete all data in the table After deleting, if you add data to the table again, the auto-incremented id will continue to be sorted downwards as before; After truncate is deleted, the auto-incremented id will not be sorted downwards. Therefore, if you want to delete all data in a table, it is recommended to use truncate. The above is the details of the MySQL DML language operation example. For more information about MySQL DML language (addition, deletion and modification), please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Ubuntu 20.04 sets a static IP address (including different versions)
>>: VMware installation of Ubuntu 20.04 operating system tutorial diagram
Today I found this prompt when I was running and ...
Table of contents 1. What is a JavaScript engine?...
The format is simple: proxy_pass URL; The URL inc...
For example, if your current path is /var/log and...
In the trend of gradual transition from tradition...
Tutorial Series MySQL series: Basic concepts of M...
Table of contents Preface 1. Deployment and Confi...
Simply pull the image, create a container and run...
Here are 10 HTML tags that are underused or misun...
1. Download Navicat for MySQL 15 https://www.navi...
1. Download the installation package -Choose the ...
Table of contents 1. Stop MySQL Server first 2. U...
What is JSX JSX is a syntax extension of Javascri...
Table of contents 1. Download the installation pa...
Table of contents What is index pushdown? The pri...