Home > Database > navicat > How to use navicat to add primary keys and auto-increment to database tables

How to use navicat to add primary keys and auto-increment to database tables

(*-*)浩
Release: 2019-08-21 17:38:07
Original
9430 people have browsed it

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.

How to use navicat to add primary keys and auto-increment to database tables

##Open the navicat tool, connect to the mysql server, after selecting the database, select a table, right-click and select [Design Table] 】 (For demonstration and testing here, just select a table) (Recommended tutorial: navicat tutorial)

How to use navicat to add primary keys and auto-increment to database tables

On the design table page, you can see all the 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 use navicat to add primary keys and auto-increment to database tables## As shown in the picture,

right-click on the last column and select the primary key to set the field as the primary key. You can also click the left mouse button directly to quickly add and cancel the primary key

How to use navicat to add primary keys and auto-increment to database tables

After setting the primary key, you can see the logo of a lock with the word 1. Because a table can add primary keys to multiple fields, it is a joint primary key, so it displays as primary key 1. , primary key 2, etc.

How to use navicat to add primary keys and auto-increment to database tables

After the primary key setting is completed, it has not been incremented yet. After selecting the id field

, check the box below as shown in the figure. Select auto-increment, so that the ID will automatically increment by a value after each record is inserted

How to use navicat to add primary keys and auto-increment to database tables

After setting the primary key and auto-increment, click Save and close the current window.

The above is the detailed content of How to use navicat to add primary keys and auto-increment to database tables. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template