Write SQL queries to check if the row is a primary column.
Use the supplied metadata tables to determine whether each registered column belongs to a primary key constraint. Include columns without matching constraints and distinguish primary key constraints from other constraint types.
table_schema, table_name, column_name, and is_primary_key.| Column | Type | Description |
|---|---|---|
| column_idPK | INT | Unique metadata identifier for a column |
| table_id | INT | Identifier of the table containing the column |
| table_schema | VARCHAR(63) | Database schema name |
| table_name | VARCHAR(63) | Table name |
| column_name | VARCHAR(63) | Column name |
| Column | Type | Description |
|---|---|---|
| constraint_idPK | INT | Unique constraint identifier |
| table_id | INT | Identifier of the constrained table |
| constraint_name | VARCHAR(100) | Constraint name |
| is_primary_key | BOOLEAN | Whether the constraint is a primary key |
| Column | Type | Description |
|---|---|---|
| constraint_idPK | INT | Referenced constraint identifier |
| column_idPK | INT | Referenced column identifier |
| ordinal_position | INT | Column position within the constraint |