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

Thread: column constraints

  1. #1
    Join Date
    Jan 2002
    Posts
    146

    column constraints

    Hi Firends,


    We have a table emp with a primary key (empno varchar2).
    I want to put a constraint on this column so that all its value
    is numeric and has fixed length of 10. Can you pls help me
    how to code this pls?


    Thank you all.

  2. #2
    Join Date
    Jan 2000
    Posts
    387
    Hi

    Since you want the column to be numeric, then why not use the type number(10) instead?

  3. #3
    Join Date
    Jan 2002
    Posts
    146
    Hi Friend,

    The column values allow leading zeroes and fixed length of 10

  4. #4
    Join Date
    Jan 2000
    Posts
    387
    Hi,

    You might need to write a procedure instead. Please refer to my posting below.

    http://www.dbasupport.com/forums/sho...threadid=41524

  5. #5
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Originally posted by rommel
    Hi Friend,

    The column values allow leading zeroes and fixed length of 10
    why does this matter? You should use a number colum for this ... if you need to you can manipulate it to leading zeroes for display purposes.

    Anyhoo, the constraint would be ...

    Code:
    check(translate(empno,'0123456789','0000000000') = '0000000000')
    ... but it's still a bad design.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

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