Voici ses principaux champs :
Nom du champ | Type du champ | Description du champ |
column_name | VarChar(64) | Nom de la colonne. |
constraint_catalog | VarChar(64) | Nom de la base de données de la contrainte. |
constraint_name | VarChar(64) | Nom de la contrainte. |
constraint_schema | VarChar(64) | Nom du schéma de la contrainte. |
ordinal_position | BigInt(10) | Numéro de la colonne. |
table_name | VarChar(64) | Nom de la table. |
table_schema | VarChar(64) | Nom du schéma de la table. |
SELECT
'',
c.table_catalog,
c.table_schema,
c.table_name,
b.constraint_name,
CASE a.constraint_type
WHEN 'UNIQUE' THEN 1
WHEN 'UNIQUE KEY' THEN 1
ELSE 0
END,
b.table_name,
b.column_name,
b.ordinal_position
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS a, INFORMATION_SCHEMA.KEY_COLUMN_USAGE b, INFORMATION_SCHEMA.TABLES c
WHERE
(a.constraint_catalog=b.constraint_catalog OR (a.constraint_catalog IS NULL AND b.constraint_catalog IS NULL))
AND a.constraint_schema=b.constraint_schema
AND a.constraint_name=b.constraint_name
AND a.table_schema=c.table_schema
AND a.table_name=c.table_name
AND c.table_catalog LIKE 'MonCatalogue%'
AND a.table_schema LIKE 'MonSchema%'
AND a.table_name LIKE 'MaTable%'
AND a.constraint_type IN ('PRIMARY KEY', 'UNIQUE', 'UNIQUE KEY')
ORDER BY c.table_schema, c.table_name, b.constraint_name, b.ordinal_position;