In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the operation method of realizing replace into in MySQL. The content of the article is carefully selected and edited by the author. It has certain pertinence and is of great significance to everyone's reference. Let's learn about the operation method of realizing replace into in MySQL with the author.
Let's take a look at the following implementation process.
Prepare the data sheet
CREATE TABLE `demo` (`id` int (11) unsigned NOT NULL AUTO_INCREMENT, `a` tinyint (1) unsigned NOT NULL DEFAULT '0commands, `b` tinyint (1) unsigned NOT NULL DEFAULT' 0levels, `c` tinyint (1) unsigned NOT NULL DEFAULT '0levels, `d` tinyint (1) unsigned NOT NULL DEFAULT' 0levels, `e`tinyint (1) unsigned NOT NULL DEFAULT '0cycles, `f`tinyint (1) unsigned NOT NULL DEFAULT' 0structures, PRIMARY KEY (`id`), UNIQUE KEY `unq_a_b_ c` (`a`, `b`) `c`) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
Note: there are two indexes in the table, with id as the primary key index and aQuery bPermec as the federated unique index.
2. Write the initial data insert into test.demo (a recital b recorder c recorder d recorder f) values (1 meme 2 recitation 3 recital 1 Jing 1)
At this point, there is unique index data composed of abc hashes: 1, 1, 2, 3.
3. To further implement replace into into demo (aPeragrum brecrium crecincdreeDifferent) values (1Mage2pence3 reparent2); because there already exist unique index data composed of three columns of abc: 1meme1, and this time it is written into demo (aQuery brecriedrecorder f) values, which will cause a unique index conflict. Therefore, the original record is deleted and a new record is added. When the replace into field has a primary key field, it will be updated that the replace into field of this record has no primark key field, and if there is a unique index conflict, the original record will be deleted, and a new record will often encounter this situation when inserting data into the table: 1. First of all, judge whether the data exists or not. If it does not exist, insert
3. If present, update
After reading the above about the operation of replace into in MySQL, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.