In this article, we’ll take a closer look at the Double Precision datatype, including its syntax, storage requirements, and performance considerations.
Introduction to Oracle Double Precision Datatype
The double precision data type in Oracle 21c is a numerical data type that is used to accurately represent decimal numbers with double precision. It is also known as double or float.
Double precision numbers are stored in 64 bits, which provides a greater range and precision than the standard float data type.
Also, check: Oracle nclob Datatype
Oracle Double Precision datatype Syntax
The syntax for declaring a column with the Double Precision datatype in Oracle 21c is as follows:
column_name DOUBLE PRECISION;
Where scale refers to the number of digits before the decimal point and precision refers to the total number of digits in the number.
For example, to create a table named “employees” with a column “salary” of double precision data type, you can use the following syntax:
CREATE TABLE employees ( id NUMBER, name VARCHAR2(50), salary DOUBLE PRECISION );
Read: Clob Datatype in Oracle Database
Example of Double Precision Datatype in Oracle 21c
Here is an example of using the double-precision data type in Oracle 21c:
CREATE TABLE sales ( id NUMBER, sale_date DATE, amount DOUBLE PRECISION );
Now we will insert the values into the following given table named ‘sales’
INSERT INTO sales (id, sale_date, amount) VALUES (1, TO_DATE('2022-01-01', 'YYYY-MM-DD'), 1234.5678); SELECT * FROM sales;
In the following example, we will make a table called “sales” with the columns “id,” “sale_date,” and “amount.” Double precision values are used for the “amount” column. Next, we add an entry with the value “amount” of 1234.5678 to the “sales” table.
Here’s another example of using the double-precision data type in Oracle 21c:
CREATE TABLE temperature_readings ( id NUMBER, reading_date TIMESTAMP, temperature DOUBLE PRECISION );
Now we will insert the values into the following given table
INSERT INTO temperature_readings (id, reading_date, temperature) VALUES (1, TIMESTAMP '2022-01-01 12:00:00', 25.7);
In this instance, we make a table called “temperature_readings” with the three columns “id,” “reading_date,” and “temperature.” The double precision data type for the “temperature” column. The “temperature_readings” table is then updated with a row that has a “temperature” value of 25.7.
Now, we will discuss how to use the Double precision datatype in the Oracle developer tool.
CREATE TABLE financial_transactions ( id NUMBER, transaction_date DATE, amount DOUBLE PRECISION, description VARCHAR2(100) );
In this instance, we create a table named “financial_transactions” with four columns: “id”, “transaction_date”, “amount”, and “description”. The “amount” column is of the Double Precision data type.
Now we will insert the values into a following given table
INSERT INTO financial_transactions (id, transaction_date, amount, description) VALUES (1, DATE '2022-01-01', 12345.67, 'Salary payment'); SELECT * FROM financial_transactions;
Here we inserted a row into the “financial_transactions” table with an “amount” value of 12345.67 and a description of “Salary payment”.
Also check: Oracle Create Index
So, In this Oracle tutorial, we understood how to define and use the double_precision 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.
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.