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.
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
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.
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).
Here are the table column names
Now we will insert the values into a table.
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);
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.
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.
- How to create a user in Oracle
- Char Datatype in Oracle Database
- How to get database name in Oracle
- How to check database status in Oracle
I am Bijay having more than 15 years of experience in the Software Industry. During this time, I have worked on MariaDB and used it in a lot of projects. Most of our readers are from the United States, Canada, United Kingdom, Australia, New Zealand, etc.
Want to learn MariaDB? Check out all the articles and tutorials that I wrote on MariaDB. Also, I am a Microsoft MVP.