Home  >  Article  >  Database  >  How to Check Primary and Foreign Key Constraints in MySQL?

How to Check Primary and Foreign Key Constraints in MySQL?

Linda Hamilton
Linda HamiltonOriginal
2024-11-03 15:56:03325browse

How to Check Primary and Foreign Key Constraints in MySQL?

How to View Primary and Foreign Key Constraints on Tables

In order to verify previously established primary and foreign key (PK/FK) relationships, you can utilize the command SHOW CREATE TABLE. This command displays the SQL statement required to recreate the specified table in its current state.

Example:

To examine the constraints on the practices and cred_insurances tables in the credentialing1 database, execute the following command:

SHOW CREATE TABLE practices;
SHOW CREATE TABLE cred_insurances;

The output will include information about table columns, data types, and constraint definitions. This allows you to confirm the PK and FK relationships you have set.

The above is the detailed content of How to Check Primary and Foreign Key Constraints in MySQL?. 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