gram77
asked on
Oracle Number Vs Oracle Float datatype
I have a table whose column is declared as number, without any precesion and scale. Still i can store float values.
so when should one use a float datatype?, and what is the difference in the two datatypes. Is a float dataype just a
alias of number datatype or is it much more?
create table dummy
(col1 number);
select * from dummy;
1
1.1
1.11
1.111
1.1111
1.11111
1.111111
1.111111111111111111111111 11111
so when should one use a float datatype?, and what is the difference in the two datatypes. Is a float dataype just a
alias of number datatype or is it much more?
create table dummy
(col1 number);
select * from dummy;
1
1.1
1.11
1.111
1.1111
1.11111
1.111111
1.111111111111111111111111
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
number and float are stored internally in same fashion.
create table t3 (
x3 number
,f3 float
);
insert into t3 (x3, f3) values (1,1);
commit;
select dump(x3) x3, dump(f3) f3 from t3;
drop table t3;
create table t3 (
x3 number
,f3 float
);
insert into t3 (x3, f3) values (1,1);
commit;
select dump(x3) x3, dump(f3) f3 from t3;
drop table t3;
ASKER
best solution
Whereas Oracle's FLOAT data type is a synonym for the ANSI SQL NUMERIC data type, called NUMBER in Oracle. This is an exact numeric, a scaled decimal data type that doesn't have the rounding behavior of IEEE 754. But if you fetch these values from the database and put them into a C or Java float, you can lose precision during this step.