Float Datatype in Oracle Database

In this Oracle tutorial, we will learn about the float datatype in the oracle database. Also, we will demonstrate how to use it to create float columns for a table.

Introduction to Oracle FLOAT datatype

Floating-point numbers of the FLOAT datatype have a binary precision of b. This datatype’s default precision is 126 binary or 38 decimals.

Due to the fact that there is no finite amount of digits after the decimal point, this is known as a floating point.

Oracle float datatype Syntax

Until now, we have understood the float datatype in a database and discussed the purpose of the floating point. Next, we will take a step further and understand how to use it to create float columns for a table.

For this, we need to understand the syntax to use a float datatype in oracle 21c which is given below.

FLOAT[(pre)]

The FLOAT Datatype in Oracle allows you to determine the precision. The scale cannot be specified since Oracle Database selects the scale based on the data. FLOAT has a 126-point precision limit.

Also, check: Oracle Database vs MySQL Database

Oracle float datatype Examples

After discussing the syntax, we will now discuss the example of how to use the float datatype in oracle 21c.

Here we will discuss how to use the float datatype in the SQL developer tool manually. First, we will click the right selection on the table folder and then click on a new table.

Recomendadtion: How to create a database in Oracle 19c

select option for creating table in oracle
select the option for creating a table in an oracle

After selecting the new table option, we will mention the name of the table. Here is the table for our example execution and this employees table is located in the pdb database.

table name in oracle developer tool
the table name in an oracle developer tool

After creating the table, we will insert the column name and provide the datatype in this example, we utilize the float datatype with size(20).

float datatype in oracle
float datatype in oracle

Here are the table column names

create employee table
create employee table

Now we will insert the values into a table.

insert values into table
insert values into the table

Example:

Now we will create a table by statement and check how we can use the float datatype in the given customers table.

CREATE TABLE customers (cust_id NUMBER(5,2), product_price FLOAT(5));

Now we will insert the values and display the float values.

INSERT INTO customers VALUES (67, 2.45);
INSERT INTO customers VALUES (23, 9.523);
create customer table in oracle
create a customer table in oracle

Read: How to Check Oracle Database Version

Oracle float default precision

The float Datatype’s default precision is 126 binary or 38 decimals.

In this article, we have covered the float datatype in the oracle database. And also we have covered the different examples of using float datatype columns for a table.

Conclusion

So, in this Oracle tutorial, we understood how to define and use the Float Datatype in Oracle Database. And we have also covered a few sample examples related to it.

Also, take a look at some more Oracle tutorials.