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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

This will help you to understand Table Level VS Column Level Constraints (…) – Kin Oct 2 '13 at 16:46
@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
up vote 6 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

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