DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: how limit datatype on columns........

  1. #1
    Join Date
    Jul 2002
    Posts
    228

    how limit datatype on columns........

    hi,
    I have this col in table tab_X

    X_ID........varchar2(32)

    I'd like to limit the insert at max 8 characters.

    For example:
    insert into tab_X (X_ID) values ('00112233');
    correct

    insert into tab_X (X_ID) values ('001122334455');
    incorrect (error)

    How can I limit X_ID at max length=8??

    Thanks

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Check constraints!

    alter table tab_X add constraint check_length check (length(X_ID)<=8);

    But don't you think your table is designed improperly? If yor X_ID should accept at most 8 characters, why do you have column declared as varchar2(32)? Why not simply define it as varchar2(8) and the propper length check will be performed automaticaly?
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

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


Click Here to Expand Forum to Full Width