Hongmu Notes
Home Language Notes Fix the id auto-increment sequence of data tables
Language Notes mySql

Fix the id auto-increment sequence of data tables

Fix the id auto-increment sequence of data tables

1. Delete the original primary key:

ALTER TABLE `table_name` DROP `id`;

2. Add a new primary key field:

ALTER TABLE `table_name` ADD `id`INT(11) NOT NULL FIRST;

3. Set a new primary key:

ALTER TABLE `table_name` MODIFY COLUMN `id`INT(11) NOT NULL AUTO_INCREMENT,ADD PRIMARYKEY(id);
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

sqlite uses PDO to execute SQL statements exec(), query()

sqlite uses PDO to execute SQL statements exec(), query() Language Notes mySql

In PHP scripts, executing SQL queries using PDO to interact with a database can be done through three different approaches; the choice of which method to use depends on the specific operation you intend to perform. 1. Using the PDO::exec() method: When executing queries such as INSERT, UPDATE, or DELETE that do not return a result set, use the exec() method on a PDO object to execute the query. Upon successful execution, this method returns the number of affected rows...
👁 323
Mysql efficiency improvement: limit this piece of shit

Mysql efficiency improvement: limit this piece of shit Language Notes mySql

In mysql, the efficiency of limit is not high, especially my millions of data, limit 100000, 50, so writing, the query is even slower, at first it was quite fast, and the server cup behind it was directly filled for me! I thought the server was hacked, so I looked for the problem. I looked for it for a few days, but it turned out to be this dog, which made me angry! So I inquired about the principle of limit, emmm, change! Must be changed ...
👁 155
SQL statement to truncate the database

SQL statement to truncate the database Language Notes mySql

The TRUNCATE command can be used to clear a table; however, if you need to clear an entire database, you must clear each table individually. Below is an example SQL statement for clearing an entire database: SET foreign_key_checks = 0; SELECT CONCAT('TRUNCATE TABLE `',table_name,'`;') FR...
👁 297
Query error: #1075-Incorrect table definition; there can be only one auto column, and it must be defined as a key.

Query error: #1075-Incorrect table definition; there can be only one auto column, and it must be defined as a key. Language Notes mySql

This error message indicates that you have defined multiple auto-increment columns when creating a table, or that you have not defined an auto-increment column as a primary key or a unique key; as a result, MySQL is unable to create the table. In MySQL, there can be only one auto-increment column, and it must be defined as a primary key or a unique key. Here are some possible ways to resolve this issue: Ensure that there is only one auto-increment column: You should check your table definition to confirm that only one column is defined as an auto-increment column. If you need...
👁 409

Recommended reading

Responsive Maternal and Child Products Franchise Website Template 0503

Responsive Maternal and Child Products Franchise Website Template 0503 Practical Collection Yiyou template

An eyouCMS responsive website template designed for the maternal and infant products franchise industry. Its warm and professional design effectively showcases maternal and infant products, franchise policies, brand stories, and store imagery, helping maternal and infant brands attract franchisees and consumers online. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for eyouCMS | eyouCMS (...
👁 64
Responsive pet food and product company website template – 0504

Responsive pet food and product company website template – 0504 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for pet food and product companies. Its warm and charming design is perfect for showcasing pet food, pet supplies, brand stories, and pet care knowledge. It helps pet brands effectively present their products online and attract pet owners. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (E...
👁 39
Simple news and information website template – 0505

Simple news and information website template – 0505 Practical Collection Yiyou template

An EyouCMS template designed for clean, news-focused websites. Its minimalist, information-flow design is ideal for publishing news articles, industry updates, trending topics, and in-depth reports. This template helps news websites attract online readers and build media influence. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (Ey...
👁 33
Resource website typecho001 template

Resource website typecho001 template Program Notes Typecho

typecho001 template template please do not modify the folder name of this template. The folder name is: typecho001 1.4 Fix the js output problem on the article page 1.3 Fix the error prompt when the plug-in is not installed Optimize the list page code output 1.2 Fix the comment function and add a custom homepage title 1.1 Fix the comment reply asymmetry function Add a separate title setting function on the homepage Add the website favicon.ico icon Add one...
👁 198
Responsive bending machine manufacturing website template 0506

Responsive bending machine manufacturing website template 0506 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for the bending equipment manufacturing industry, featuring a professional industrial design style that effectively showcases bending equipment products, manufacturing processes, technical specifications, and industrial applications. It enables machinery and equipment enterprises to present their products online and attract industrial customers. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 34
Modification of typecho paging style

Modification of typecho paging style Program Notes Typecho

Sir, times have changed! Typecho is currently the most perfect solution, because Baidu can only see the code of fixed thinking. The actual generated HTML code is breathtakingly clean and fully customized, including adding classes to the li element, adding classes to the a element, adding classes to the previous page and next page, and removing the li tags that come with typecho to express more. I can even add some text to the content inside...
👁 517