Home > Database > Mysql Tutorial > body text

How to Check Primary and Foreign Key Constraints in MySQL?

Linda Hamilton
Release: 2024-11-03 15:56:03
Original
324 people have browsed it

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;
Copy after login

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!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template