Real Datatype Oracle

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

Introduction to Oracle Real Datatype

In Oracle 21c, single-precision floating-point integers are stored in the REAL datatype, a floating-point datatype. In some other databases, it is also referred to as the FLOAT datatype.

Oracle Real datatype Syntax

The syntax for declaring a column of Real datatype in Oracle 21c is as follows:

column_name REAL;

The REAL datatype is used to store approximate numeric data values. It is represented in 32 bits and can store a range of values from -3.4028235E38 to 3.4028235E38.

The precision of the REAL datatype is approximately seven decimal digits. The REAL datatype is often used in scientific calculations where precision is not a critical factor.

Also, check: Char Datatype in Oracle Database

Oracle Real datatype Example

Here is an example of the REAL datatype in Oracle 21c:

CREATE TABLE employees (
  emp_salary REAL
);

In this example, we create a table named employees with a single column named emp_salary of type REAL.

Now we will insert the values into an employee table in oracle

INSERT INTO employees (emp_salary) VALUES (4.14);

select * from employees;
using the real datatype in oracle
using the real datatype in oracle

Read: Oracle nclob Datatype

Example:

Now we will use the Real datatype in a SQL developer tool using oracle 21c.

In this given example, we create a table called “Customers” with two columns: “cust_id” and “cust_salary”. The “cust_salary” column is of type Real.

use the real datatype in sql developer tool
use the real datatype in the SQL developer tool

Now we will insert the values into a following given table

INSERT INTO customers (cust_salary) VALUES (4.14);

select * from customers;
insert the values into a customer table
insert the values into a customer table

Advantages of oracle real datatype

  • Small storage: Because a REAL data type only requires 4 bytes of storage, it is a good choice for large databases that require a lot of data.
  • High accuracy: The REAL data type, which offers a high degree of precision, is suited for scientific or financial applications where precision is essential.
  • Speed: The REAL data type is built for rapid processing, making high-performance computing applications a good fit for it.
  • Because it is compatible with so many different programming languages, a REAL data type is a fantastic choice for developers that need to work with a variety of frameworks or languages.

Also, check: Oracle long raw Datatype

Features of oracle real datatype

  • Storage Efficiency: The REAL datatype uses less storage than the DOUBLE PRECISION or NUMBER datatypes, requiring only four bytes per value.
  • Calculations can be performed with a high degree of precision because to the floating-point representation used by the REAL data type.
  • Widely Used: The REAL datatype is frequently used in engineering and scientific applications that need accurate floating-point calculations.

Conclusion:

So, in this Oracle tutorial, we understood how to define and use the real 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.