Oracle express 11g? Constraints

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BAHA
    New Member
    • May 2012
    • 2

    Oracle express 11g? Constraints

    I want to set up a CHECK constraint for an ID i.e CON12345, it has to have those three characters "CON" at the front and 5 numbers that follows that?
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    if this is a new table you can saet check when you create table
    Code:
    create table test (
    id varchar2(9), 
    constraint id_chk check(regexp_like(id,'CON[0-9]{5}'))
    );
    if table already exist you can add check constraint
    Code:
    alter table test add constraint id_chk(check(regexp_like(id,'CON[0-9]{5}'))

    Comment

    • BAHA
      New Member
      • May 2012
      • 2

      #3
      Thanks it works. i found all of these types of constraints on oracle's website

      Comment

      Working...