Skip to content
Advertisement

Select a list of keys of a table in MySQL

Say I have a table “products” and I would like to check if this table has any indexes, foreign keys etc

A “DESCRIBE products” would give some information.

Field        Type           Null    Key    Default   Extra
productCode  varchar(200)   NO      MUL    NULL  
description  varchar(500)   NO             NULL 

Mainly the key field in the case. But defenietly no references and what table is linked to who etc etc.

What is the best way to get such information via SQL about a table?

Thanks

Advertisement

Answer

You can use

SHOW CREATE TABLE products

which gives you the query for creating the table. The most informative.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement