Open the navicat tool, connect to the mysql server, after selecting the database, select a table, right-click and select the design table (for demonstration and testing here, just select any table)
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 figure, right-click on the last column and select Primary Key to set the field as the primary key. You can also directly click the left mouse button to quickly add and cancel the primary key.
Related recommendations: "Navicat for mysql graphic tutorial"
After setting the primary key, you can see a lock The identifier, 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.
After the primary key is set, it has not been auto-incremented yet. After selecting the id field, as shown below, check Auto-increment, so that the id will be automatically incremented every time a record is inserted. Increment a value.
After setting the primary key and auto-increment, click Save, close the current window, and then right-click the table name to select object information.
In the DLL page, you can see the primary key and the auto-incremented DLL statement just added. Here is the DLL statement to create the table.
As mentioned above, a joint primary key is mentioned. In fact, a table can set primary keys for multiple fields, which can form a joint primary key. For specific businesses, a joint primary key is also necessary.
The above is the detailed content of How to set up auto-increment in navicat. For more information, please follow other related articles on the PHP Chinese website!