0

I know this is very simple, but how do I do this in plain SQL?

1
  • What sort of a constraint? A unique constraint? Commented Dec 3, 2009 at 19:52

2 Answers 2

3

For a unique constraint during table creation:

CREATE TABLE T1 (
    Col1 int NOT NULL,
    Col2 int NOT NULL,
    UNIQUE (Col1, Col2)
)

After table creation:

ALTER TABLE T1 ADD UNIQUE (Col1, Col2)
Sign up to request clarification or add additional context in comments.

Comments

0

Are you talking about check constraints?

alter table MyTable add constraint CC_Dates check (FromDate < ToDate)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.