How can i set a column in oracle to not accept numbers above 10000 and below 0?
Asked
Active
Viewed 3,617 times
1 Answers
7
You are looking for a check
constraint:
alter table t add constraint chk_t_col check (col >= 0 and col <= 10000);
This will prevent inserting or updating any values in the column that are not in the specified range.

Gordon Linoff
- 1,242,037
- 58
- 646
- 786
-
Thank you so much it worked !!!!!!! – FenrisL Mar 11 '17 at 11:34
-
Can i ask you one more thing? In the same way i can validate an email address before its inserted? – FenrisL Mar 11 '17 at 11:40
-
@NikosL24 . . . You can validate any column with a `check` constraint. For an email, you would probably use a regular expression. – Gordon Linoff Mar 11 '17 at 13:35
-
I've been searching about that.... how can you do a check before the INSERT so it displays an error ? – FenrisL Mar 11 '17 at 14:01
-
@NikosL24 . . . That is what a `check` constraint does. – Gordon Linoff Mar 11 '17 at 14:01