In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
How to use mysql to generate unique serial numbers? In cases where the database is divided into tables or the program itself needs a unique id, we need a scheme to generate a unique id.
You can write a program that combines time and some features to generate a unique id, or you can consider using the self-adding id feature in the database to achieve this requirement. Here is an example of mysql.
First, create a table that specifically generates id, where the id field is the primary key and the replace_key field is the unique key.
CREATE TABLE `ticket` (`id` bigint (20) unsigned NOT NULL auto_increment, `replace_ key` char (1) NOT NULL default'', PRIMARY KEY (`id`), UNIQUE KEY `replace_ key` (`replace_ key`) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10001
Each time you need to generate an id, use the replace into statement to generate a new record to replace the old record, and then return to this id.
REPLACE INTO `ticket` (`ticket`) VALUES ('a'); SELECT LAST_INSERT_ID ()
The above is a brief introduction to how to use mysql to generate a unique serial number, of course, the detailed use of the above differences have to be used by everyone to understand. If you want to know more, welcome to follow the industry information channel!
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.