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.
##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)
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
## As shown in the picture,
, 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
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!