Some time we need to get all tables which have primary key constraints. There are many way to get this information.
Select ISTC.Table_CatalogasBD_Name, ISTC.Table_SchemaASTBL_SCHEMA, ISTC.Table_NameASTBL_NAME, ISCCU.Column_NameASCOL_NAME, ISTC.Constraint_NameASCONSTRAINT_NAME From information_Schema.Table_ConstraintsISTC INNERJOIN Information_Schema.constraint_column_usageISCCU onISTC.Constraint_Name=ISCCU.Constraint_Name ANDISTC.Table_Name=ISCCU.Table_Name where Constraint_Type='PRIMARY KEY' |
This one is the best query to find out the tables which have primary key because information schema provides more information and all the data can be retrieved with the filtered filter.