Numeric Datatype

By default:

  • The precision p can range from 1 to 38
  • The scale s can range from -84 to 127
  •  A NUMBER value requires from 1 to 22 bytes

Requirements

  • Precision: number of digits the computer has to store
  • Scale: Number of digits after decimal

For example, if we look at 12345.67

Precision = 7

Scale = 2

 

Example # 2

Let us look at number and determine the Datatype that would be best.

0.1234567

If we had to store both of the above numbers in the same datatype, what would be the requirements?

Combined, the number would look something like this: 12345.123456

It would have to be able to hold 12 digits:

Precision = 11

Scale = 6

 

Example code

—CREATEA A TABLE

CREATE DATABASE Students (

ID_FIELD NUMERIC(6, 2),

)

— INSERTING VALUES

INSERT INTO Students

VALUES (5.25)

 

View list of datatypes

Documentation link

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top