HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

Is there anything a table-level constraint declaration can do that a column-level one can not do?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
candeclarationcolumnanythinglevelonethatconstrainttherenot

Problem

Had an exam today. One question disturbed me:


What can a table-level constraint do that a column-level constraint can't do?

My answer was that only a table-level constraint declaration permits setting up a composite primary key. I guess this is not the only difference. How could I have added to that?

Solution

You've forgotten about other types of constraint than primary key (also applies to unique, check, and foreign key constraints) but that's basically it.

A column-level constraint can only reference the column that it is declared next to. A table-level constraint can reference multiple columns.

Context

StackExchange Database Administrators Q#50885, answer score: 14

Revisions (0)

No revisions yet.