REAL
REAL is a data type in SQL used to store floating point numbers with 7 digits of precision. It can be used to save space when the higher precision provided by DOUBLE is not necessary. Being a floating point type, it is used to represent fractional numbers and can handle exponential values as well.
Example
Output
Explanation
In this example, we have a SQL table named Inventory
with three fields: ItemID
, ItemName
and ItemWeight
. ItemID is an integer, ItemName is a text string, and ItemWeight is a REAL data type. The REAL
data type is a floating-point number with seven digits of precision that can accept data values from -3.4E38 to 3.4E38.
In the INSERT INTO command, we insert two rows of data into the Inventory
table. The ItemWeight for each row is expressed as a REAL data value. Using the SELECT command, we display the contents of the Inventory
table.
Example
Output
Explanation
In the example, a new table test_table
is created with one column column1
with the data type REAL
. The REAL
data type in PostgreSQL is used to store single precision floating point numbers. A value of 123.45
is then inserted into column1
. Finally, all data from test_table
is selected, which in this case shows the inserted 123.45
.
Example
Output
Explanation
The example demonstrates how to declare a REAL
data type variable @RealValue
, set a value to it, and then select the value. The REAL
data type is a floating point number data type that can be used to store fractional numbers with up to seven digits of precision.
Example
Output
Explanation
In the code example, a new table ‘Employee’ is created with ‘ID’ and ‘Salary’ columns. The ‘Salary’ column uses the REAL datatype, which is designed to store decimal or floating point values in SQLite. Three rows of data are then inserted into the table using the INSERT INTO statement. Finally, the SELECT statement is used to fetch and display all data from the ‘Employee’ table. The output shows the values of ‘ID’ and ‘Salary’ columns from all rows.