Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to limit numeric columns to 32-bit and 64-bit values

user633661Apr 29 2010 — edited Apr 29 2010
Hi,

Is it possible to somehow limit the column datatype to 32-bit (or 64-bit) signed integer range of positive values, so that the permitted values would be within 0.. 2,147,483,647 for the 32-bit and 0.. 9,223,372,036,854,775,807 for the 64-bit. The reason is that we are using Java datatypes int and long to read data from the database and would like to constrain the maximum values at the database level.

An approach would probably be to define columns as NUMBER(10, 0) (or NUMBER(19, 0) for 64-bits) and add a CHECK constraint which would guarantee the value is within the boundaries, but is there any other solution? Unfortunately constrained datatypes http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/datatypes.htm#CHDBBCIE are available only in PL/SQL.

Thanks in advance.

Regards,
Jure
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 27 2010
Added on Apr 29 2010
6 comments
2,275 views