High-available virtual servers
Elastic bare metal computing service
Featured stable and capable
Distribute secure and stable traffic
One-stop E-certificate management
Protect your application from CC and DDoS Attacks
When using a MySQL instance, the following three methods are commonly used to view primary key fields. Select a method based on your needs.
Run the following SQL statement to confirm the primary key fields in the system table.
SELECT t.TABLE_NAME,t.CONSTRAINT_TYPE,c.COLUMN_NAME,c.ORDINAL_POSITIONFROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS t,INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS cWHERE t.TABLE_NAME = c.TABLE_NAMEAND t.CONSTRAINT_TYPE = 'PRIMARY KEY'AND t.TABLE_NAME='[$Table_Name]'AND t.TABLE_SCHEMA='[$DB_Name]';
Run the following SQL statement to confirm the primary key fields through the table creation statement.
show create table [$Table_Name];
Run the following SQL statement to confirm the primary key field based on the table structure.
desc [$Table_Name];
Yisu Cloud Ltd.
E-mail : support@yisu.com
Copyright © Yisu Cloud Ltd. All Rights Reserved. 2022