Can we restrict the Values of the Field while creating table it self?

Database

Can we restrict the Values of the Field while creating table it self?

Hi ,

I need a quick help in understanding the different methods while creating the table and restricting data with in it.

here is the example:

create multiset table abc.xyz

(username varchar(30),

col1 char(3),

col2 char(3)

)

primary index(username);

I want to restrict col1 data as either yes or no while data is inserting into the table itself, it should through error if i insert neither yes nor NO.

I am trying with check constarint, where it is for only with in the range .Please let me know if there are any other constraints that I can restrict the field?

Thanks

2 REPLIES
N/A

Re: Can we restrict the Values of the Field while creating table it self?

You probably tried the very old proprietary syntax: col1 char(3) BETWEEN ... AND ...,

Simply use Standard SQL:

col1 char(3) CHECK(col1 IN ('yes','no')

Dieter

Re: Can we restrict the Values of the Field while creating table it self?

Kewl,

Thank you soo much