Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Had an exam today. One question disturbed me:

  • Q: What can a table constraint do that a column constraint can't do?
  • A: My answer was that only a table constraint can declare a composite primary key.

I guess this is not the only difference. How to answer this question more precisely?

share|improve this question

closed as off-topic by Kin, Max Vernon, RolandoMySQLDBA, bluefeet, Mark Storey-Smith Oct 3 '13 at 22:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Shopping list question - questions about which tool, library, product or resource you should use are off-topic here because they quickly become obsolete and often are just about the preferences of the answerer. If you have an issue with or a question about a specific tool, please revise your question to conform to that scope." – Kin, Max Vernon, RolandoMySQLDBA, bluefeet, Mark Storey-Smith
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
This will help you to understand Table Level VS Column Level Constraints (social.technet.microsoft.com/wiki/contents/articles/…) –  Kin Oct 2 '13 at 16:46
3  
@Kin - That article is somewhat misleading. Once created they are both stored in the same way in SQL Server and not treated any differently AFAIK. It implies any change in the row will cause re-evaluation of table level constraints. –  Martin Smith Oct 2 '13 at 17:21
add comment

1 Answer

up vote 5 down vote accepted

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 is declared next to. A table level constraint can reference multiple columns.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.