How can I write check constraint for one column say class_id
where check condition should be: string started with CLS
and followed by any 5 digit number.
for e.g: CL100987
, CLS45678
try using regex
something like that
WHERE REGEXP_LIKE (COLUMN_CONDITION,'^CLS.*([0-9]{5})');
| REGEXP_LIKE -> like specific to regex | column_condition -> explicit | '^**." -> start with and followed by any char | ([0-9]) - > only numerics | {5} -> the number of numerics in the expression
pay attention to your dbms, some differences hope this could help