Atif Sheikh
Atif Sheikh

Reputation: 115

NUMBER is automatically getting converted to DECFLOAT

I am new with DB2. I am trying to run an alter query on an existing table.

Suppose the EMP table is Already there in db which have below columns

id int name varchar(50)

Now I am trying to Add a new column Salary for that I am running below query.

ALTER TABLE EMP ADD SALARY NUMBER

The above query run successfully. After that I described the EMP table it gave me below result:

ID INTEGER NAME VARCHAR SALARY DECFLOAT

As I am trying to add a column with NUMBER datatype, I dont know how NUMBER is getting converted to DECFLOAT.

It will be helpful if anybody can explain this.

Db2 version details are as follow :

Service_Level: DB2 v11.1.2.2

Fixpack_num : 2

Upvotes: 0

Views: 407

Answers (1)

mao
mao

Reputation: 12287

For Db2 for Linux/Unix/Windows, with NUMBER data type enabled (it is not the default), this is the documented behaviour.

Specifically

The effects of setting the number_compat database configuration parameter to ON are as follows. When the NUMBER data type is explicitly encountered in SQL statements, the data type is implicitly mapped as follows:

If you specify NUMBER without precision and scale attributes, it is mapped to DECFLOAT(16).
If you specify NUMBER(p), it is mapped to DECIMAL(p).
If you specify NUMBER(p,s), it is mapped to DECIMAL(p,s).

Upvotes: 3

Related Questions