I am facing issue adding constraint to the column of table in oracle- The column is defined with the datatype char(500 char). I need to put the constraint which allows only the digits and N/A value to be inserted in the column.
2 Answers
From this article stack overflow article: Oracle 11g - Check constraint with RegEx you can see that regex works on check constraints.
A regex which supports what you want would be:
^([0-9]+|N/A)$
^ at start of expression means start of line/row/text;
[0-9]+ digits 1 to x;
| or operator;
N/A a specific text;
$ end of line/row/text
2 Comments
smrita
Thanks ... But this regex is allowing me to insert other charaters as well :(
Markus Zaczek
I got a problem testing it right now. But i guess i missed the boundaries from where to where the string has to be found. I'll update my answer.