sqliteHow do I store and retrieve float values in SQLite?
Storing and retrieving float values in SQLite is a simple task. To store float values, you can use the REAL
data type. For example, the following SQL statement creates a table with a float column:
CREATE TABLE mytable (
id INTEGER PRIMARY KEY,
value REAL
);
To insert float values into the table, use the INSERT INTO
statement:
INSERT INTO mytable (value) VALUES (3.14);
To retrieve float values from the table, use the SELECT
statement:
SELECT * FROM mytable;
The output would look something like this:
id value
1 3.14
Code explanation
CREATE TABLE
statement - used to create a table with a float columnINSERT INTO
statement - used to insert float values into the tableSELECT
statement - used to retrieve float values from the table
Here are some ## Helpful links
More of Sqlite
- How can SQLite and ZFS be used together for software development?
- How do I import data from a SQLite zip file?
- How do I use a SQLite viewer to view my database?
- How do I use SQLite transactions?
- How do I call sqlitepcl.raw.setprovider() when using SQLite?
- How do I use SQLite to retrieve data from a specific year?
- How can I use the XOR operator in a SQLite query?
- How do I use the SQLite Workbench?
- How to use SQLite's strftime function?
- How do I use the correct syntax for SQLite?
See more codes...