Detailed explanation of MySQL database addition, deletion and modification operations

Detailed explanation of MySQL database addition, deletion and modification operations

Inserting Data

insert into table name (column name 1, column name 2, column name 3) values ​​(value 1, value 2, value 3);

insert into user(user_id,name,age) values(1,'nice',24);

The simple way to write it is to omit the field name, but all fields must be inserted.

Batch Insert

Efficiency issues of single and batch insertion

The efficiency of inserting multiple records in MySQL is greater than that of inserting a single record.

Deleting Records

delete from table name [where condition]

If no conditions are specified, all data in the table will be deleted one by one.

What is the difference between delete and truncate?

delete: belongs to DML, deletes data in the table one by one

truncate: belongs to DDL, delete the table first and then rebuild it

Which one is more efficient in deleting data, delete or truncate?

If the data is small, delete is more efficient

If the amount of data is large, truncate is more efficient

Update Record

update table name set column name = column value, column name 2 = column 2 value [where condition]

Modify multi-field data

Modify all (use with caution)

The above is a detailed explanation and integration of the MySQL database addition, deletion and modification operations introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • How to solve the problem of case insensitivity in MySQL queries
  • MySQL optimization strategy (recommended)
  • Detailed explanation of how MySQL solves phantom reads
  • Detailed explanation of the 10061 unknown error when using Navicat to connect to a remote Linux MySQL database
  • How to add index to mysql using shell script
  • MySQL character set garbled characters and solutions
  • MySQL starts slow SQL and analyzes the causes
  • Will MySQL execute the update statement again if it has the same data as the original one?
  • Reasons and solutions for slow MySQL query stuck in sending data
  • What should I do if I want to cancel an incorrect MySQL command?

<<:  Implementation of Nginx configuration of multi-port and multi-domain name access

>>:  Implementing access control and connection restriction based on Nginx

Recommend

A Preliminary Study on Vue Unit Testing

Table of contents Preface Why introduce unit test...

Implementation of MySQL5.7 mysqldump backup and recovery

MySQL backup Cold backup:停止服務進行備份,即停止數據庫的寫入Hot ba...

Some suggestions for Linux system optimization (kernel optimization)

Disable swap If the server is running a database ...

About WSL configuration and modification issues in Docker

https://docs.microsoft.com/en-us/windows/wsl/wsl-...

InnoDB type MySql restore table structure and data

Prerequisite: Save the .frm and .ibd files that n...

Detailed process of building mysql5.7.29 on centos7 of linux

1. Download MySQL 1.1 Download address https://do...

A brief discussion on the semantics of HTML and some simple optimizations

1. What is semanticization? Explanation of Bing D...

Mysql sorting to get ranking example code

The code looks like this: SELECT @i:=@i+1 rowNum,...

Optimize MySQL with 3 simple tweaks

I don't expect to be an expert DBA, but when ...

A brief analysis of Vue's asynchronous update of DOM

Table of contents The principle of Vue asynchrono...

CSS3 to achieve menu hover effect

Result: html <nav id="nav-1"> <...

Detailed explanation of MySQL database isolation level and MVCC

Table of contents 1. Isolation Level READ UNCOMMI...