A column should have its field as either 'cl', 'sl' or 'el'. How to add such constraints in oracel sql ?
2 Answers
You can try to use the CHECK constraint like this:
CREATE TABLE myTable
(
id int NOT NULL,
col varchar(10)
CONSTRAINT chk_col CHECK (col IN ('cl', 'sl', 'el' ))
)
or use ALTER command like
alter table mytable
add col varchar(10)
constraint chk_col check(col IN ('cl', 'sl', 'el' ))
1 Comment
Rahul Tripathi
@gopal:- Use the alter table command which I have added in my answer,
If the column is to contain 'cl', 'sl' or 'el' only, then these strings certainly have meanings. You can simply add a check constraint to your table, but that would leave the matter rather undocumented.
For this reason you may want to add a small lookup table instead:
leave description cl Casual Leave sl Sick Leave el Earned Leave
In your existing table you'd simply put a foreign key constraint to that lookup table then.