Home >Database >navicat >How to set the primary key to auto-increment in Navicat

How to set the primary key to auto-increment in Navicat

angryTom
angryTomOriginal
2019-08-06 15:24:5330391browse

How to set the primary key to auto-increment in Navicat

After the MySQL database creates a table, in order to have a unique ID to identify a certain record, this ID can be set as the primary key and auto-increment, so that when inserting When a new record is added, it will be automatically incremented with the previous ID. You can set the primary key and auto-increment for the table through SQL, or you can use the tool navicat to set the primary key and auto-increment graphically.

Recommended tutorial: MySQL database introductory video tutorial

## 1. Open the navicat tool, connect to the mysql server, and select After completing the database, select a table and right-click to select the design table (for demonstration and testing here, just select any table)

How to set the primary key to auto-increment in Navicat

 2. On the design table page, you can see All field information of the current table. The student table we selected has an id field. Currently, the table does not have a primary key field

How to set the primary key to auto-increment in Navicat

 3. As shown in the figure, right-click on the last column to select the primary key , you can set this field as the primary key, or you can directly click the left mouse button to quickly add and cancel the primary key

How to set the primary key to auto-increment in Navicat

4. After setting the primary key, you can see a The identification of the lock, and there is a 1 word, because a table can add primary keys to multiple fields, it is a joint primary key, so it is displayed as primary key 1, primary key 2, etc.

How to set the primary key to auto-increment in Navicat ## 5. After the primary key is set, it has not been incremented yet. After selecting the id field, as shown in the figure below, check Auto-increment, so that the id will increment by a value every time a record is inserted

The above is the detailed content of How to set the primary key to auto-increment in Navicat. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn