What Is Real Data Type in Oracle?

//

Scott Campbell

The Real data type in Oracle is used for representing single-precision floating-point numbers. It is a binary floating-point number that can represent values with a decimal part.

The Real data type is also known as FLOAT or FLOAT(p), where ‘p’ represents the precision (the total number of digits).

Creating a Real Data Type Column

To create a Real data type column in Oracle, you can use the following syntax:

CREATE TABLE table_name (
   column_name REAL(p)
);

In the above syntax, replace ‘table_name’ with the name of your table and ‘column_name’ with the desired name for your column. You can also specify the precision by replacing ‘p’ with the desired value.

Inserting Values into a Real Data Type Column

To insert values into a Real data type column, you can use the standard INSERT INTO statement:

INSERT INTO table_name (column_name)
VALUES (value);

In the above syntax, replace ‘table_name’ with the name of your table, ‘column_name’ with the name of your Real data type column, and ‘value’ with the actual value you want to insert.

Selecting Values from a Real Data Type Column

To select values from a Real data type column, you can use a simple SELECT statement:

SELECT column_name
FROM table_name;

In the above syntax, replace ‘column_name’ with the name of your Real data type column and ‘table_name’ with the name of your table.

Example

Let’s say we have a table called ‘Products’ with a Real data type column named ‘price’. We want to insert and select values from this column.

CREATE TABLE Products (
   price REAL(6)
);

INSERT INTO Products (price)
VALUES (9.99);

SELECT price
FROM Products;

In the above example, we create a table called ‘Products’ with a Real data type column named ‘price’ that can hold up to 6 digits. We then insert the value ‘9.99’ into the ‘price’ column and finally select all the values from the ‘price’ column.

Conclusion

The Real data type in Oracle is useful for storing single-precision floating-point numbers. It allows you to represent decimal values with a certain precision. By using appropriate SQL statements, you can easily create, insert, and select values from a Real data type column in Oracle.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy