Search code examples
sqloracle11gcheck-constraints

A column with Check constraint that accepts only caps A to caps Z


I have a column of varchar2(30) with not null and check constraint.

My problem is, I want that column to accept only caps A to caps Z only by using check constraint. How do I do this?


Solution

  • CONSTRAINT check_column_name CHECK (REGEXP_LIKE(column-name, '^[A-Z]+$'));
    

    Here's an sqlfiddle exemplifying it.