Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the skills of using MySQL

Shulou Source: shulou.com Published: 2022-06-02 03:57:19 10月03日 Update

This article mainly introduces the use of MySQL skills, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Replace into

The function of replace into is similar to that of insert, except that replace into first tries to insert data into the table, and if it finds that there is already this row of data in the table (judged by the primary key or unique index), then delete the row of data, and then insert new data. Otherwise, insert the new data directly. The biggest advantage of using REPLACE is that you can combine DELETE and INSERT into one to form an atomic operation. When using REPLACE, there must be a unique index in the table, and the field in which the index is located cannot allow null values, otherwise REPLACE will be exactly the same as INSERT.

On duplicate key update

If ON DUPLICATE KEY UPDATE is specified, and inserting a row causes duplicate values in an UNIQUE index or PRIMARY KEY, the old row UPDATE is executed.

Ignore

INSERT IGNORE INTO `email` (`email`, `phone`, `user_ id`) VALUES ('test9@163.com',' 9999999, '9999')

If you use the primary key primary or unique index unique to distinguish the uniqueness of the record, you can use it to avoid repeatedly inserting the record, so that it will be ignored when there are duplicate records, and the number 0 will be returned after execution.

Thank you for reading this article carefully. I hope the article "what are the skills for using MySQL" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Data index article use skill skill difference maximum merge into one difference value interest function atom at the same time uniqueness benefit field that is location number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS Shulou Information Xiaomi Microsoft