How to find the length of a number field?


I have created a table using the following format:

create table employee
( id number(7) PRIMARY KEY,
  name varchar2(30),
  salary number(8,2)
)

When I use SQL Plus: describe employee, the correct column definition is returned.

However, if I query from the user_tab_columns (or col) table/view, the data_length of the number fields is incorrect.

The data_length for columns with data type "number" is always 22. Thus number(8,2) becomes number(22)
and number(7) becomes number(22).



Ans:
Instead of data_length, you should look at data_precision and data_scale.

I think the data_length of 22 represents the maximum size of a variable length numeric column. Note that ALL numeric columns are variable length in Oracle.
 

Hosted by www.Geocities.ws

1