Sam Stoelinga
Sam Stoelinga

Reputation: 5021

How to create an Oracle number with at least 11 digits?

I need to create a datatype, which supports numbers with at least x digits and be able to store also more than x digits.

In TCPE the datatype is called NUM(m[,n]). M means an unsigned numeric value with at least m total digits, of which n Digits are to the right after the decimal point.

So NUM(11) how would I create a datatype for this in oracle?

I was thinking about NUMBER(11,0) but seems this is the maximum amount of bits. Maybe floating point is able to solve this problem?

Or should I use a check constraint? But using a check constraint seemed a little bit strange as I thought this would be natively supported.

Upvotes: 2

Views: 2388

Answers (1)

zerkms
zerkms

Reputation: 254926

It is not possible to declare the numeric type that contains "at least x digits and be able to store also more than x digits".

All you can do is just declare it as NUMBER(38,0) (the largest possible integer) and create constraint to check if the number is less than X digits length.

UPD

Also as you mentioned yourself NUMBER(*, 0) is also a valid way to do the same work.

Upvotes: 4

Related Questions