Example of REAL Datatype
Example 1: Storing a simple floating-point number in a SQLite database using the REAL data type.
CREATE TABLE example_real (
id INTEGER PRIMARY KEY,
value REAL
);
INSERT INTO example_real (value) VALUES (123.456);
SELECT * FROM example_real;
Output:
Explanation: In the above query, we creates a table example_real
with columns id
(as the primary key) and value
(of type REAL
), inserts a row with the value
123.456 into the table and finally retrieves all rows from the table example_real
.
Example 2: Storing a very large floating-point number in a SQLite database using the REAL data type.
CREATE TABLE example_large_real (
id INTEGER PRIMARY KEY,
value REAL
);
INSERT INTO example_large_real (value) VALUES (12345678901234567890.123456789);
SELECT * FROM example_large_real;
Output:
Explanation: In the above query, we creates a table example_large_real
with columns id
(as the primary key) and value
(of type REAL
), inserts a row with the value
12345678901234567890.123456789 into the table and finally retrieves all rows from the table example_large_real
.
REAL vs NUMERIC in SQLite
When working with SQLite, understanding the differences between data types is important for efficient database design and query performance. Two common data types often confused are REAL
and NUMERIC
. While both can store numeric values, they have distinct characteristics that impact how data is stored and processed. In this article, we will learn about what is REAL
and NUMERIC
along with the examples and also see the differences between them.
Contact Us