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

Please let me know if below two declarations are same.

create table R1
  b INT references K(w));

Note: K is a table with single attribute w as primary key

create table R1
  b INT CHECK (b in (SELECT w FROM K));
share|improve this question
If K(w) is a primary or unique key, they are similar declarations. But most SQL products accept only the first syntax (FOREIGN KEY constraint) and not the second (which has a subquery in a CHECK constraint) – ypercubeᵀᴹ Jun 16 '14 at 8:52

Not exactly - with your second CREATE statement, the same value of b can occur multiple times in table K, whereas with the first statement, it will occur once and once only. It's unusual - what are you trying to achieve?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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