Results 1 to 2 of 2

Thread: like constraint

  1. #1
    Join Date
    Mar 2009
    Posts
    1

    Unanswered: like constraint

    hi

    i am new to oracle

    i need to create a constraint that will allow a field to only have character 'A-Z'

    urgently needed

  2. #2
    Join Date
    Nov 2003
    Posts
    2,934
    Provided Answers: 12
    Code:
    CREATE TABLE check_test 
    (
      some_data    VARCHAR2(10) NOT NULL,
      CONSTRAINT character_check CHECK(REGEXP_LIKE (some_data,'[A-Z]+'))
    );
    If you want to allow lowercase letters as well you'll need to use
    REGEXP_LIKE (some_data,'[A-Za-z]+')

    More details in the manual:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm#i1048942

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •