Skip to Main Content
  • Questions
  • Integer shows as both number(22) and number(38) ?

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Leslie.

Asked: May 13, 2017 - 12:43 am UTC

Last updated: May 14, 2017 - 5:03 am UTC

Version: 12.1.0.2.0

Viewed 10K+ times! This question is

You Asked

Dear AskTom,

What don't I understand about how integers and numbers are stored? I create a column of type integer. Do a describe on the table and see number(38) and then do a select on the data dictionary and see number(22).

Thank you!

SQL> create table nico (nico_int integer);

Table created.

sys@orcl
SQL> descr nico
Name Null? Type
----------------------------------------------------------------------- -------- ------------------------------------------------
NICO_INT NUMBER(38)

sys@orcl
SQL> select column_name, data_type, data_precision, data_length from dba_tab_columns where table_name = 'NICO';

COLUMN_NAME
------------------------------
DATA_TYPE
--------------------------------------------------------------------------------------------------------------------------------
DATA_PRECISION DATA_LENGTH
-------------- -----------
NICO_INT
NUMBER
22



and Connor said...

It is to do with the NUMBER datatype.

We can store 38 digits of *precision*, ie, significant digits, and to dos, might consume up to 22 *bytes* internally.

For example

SQL> create table t (
  2    x1 number(10,5)
  3  );

Table created.

SQL>
SQL> insert into t values (123.456);

1 row created.

SQL>
SQL> select dump(x1) from t;

DUMP(X1)
------------------------------------
Typ=2 Len=5: 194,2,24,46,61


In this case, we have 6 significant digits, but we managed to store it using only 5 bytes.

Is this answer out of date? If it is, please let us know via a Comment