I am trying to add a CHECK constraint to my column for a football game score. The format has to be like such --> 4-2 (with the hyphen) Also both numbers cannot exceed 999.
Below is what I have so far which obviously does not work..Any ideas?
Column data type is VARCHAR(7)
Constraint ScoreCheck CHECK(Score LIKE '0-999'-'0-999');
The correct way to do this is to use a view or virtual column. Virtual columns are available since 11g. Simply define the virtual column in the table, such as:
(You can also use
alter table
for an existing table.)Here is a bit of a primer on virtual columns.