sqliteHow do I use different data types in SQLite?
SQLite supports a variety of data types including NULL, INTEGER, REAL, TEXT, BLOB.
-- Create a table with different data types
CREATE TABLE table_name (
column_1 INTEGER,
column_2 REAL,
column_3 TEXT,
column_4 BLOB
);
-- Insert a row with different data types
INSERT INTO table_name (column_1, column_2, column_3, column_4)
VALUES (1, 3.14, 'Hello SQLite', 'ABC');
The example code creates a table with four columns of different data types and inserts a row with different data types.
Code explanation
-
CREATE TABLE table_name (column_1 INTEGER, column_2 REAL, column_3 TEXT, column_4 BLOB);- This code creates a table named
table_namewith four columns of different data types:column_1ofINTEGERtype,column_2ofREALtype,column_3ofTEXTtype andcolumn_4ofBLOBtype.
- This code creates a table named
-
INSERT INTO table_name (column_1, column_2, column_3, column_4) VALUES (1, 3.14, 'Hello SQLite', 'ABC');- This code inserts a row into
table_namewith different data types:column_1is ofINTEGERtype with value1,column_2is ofREALtype with value3.14,column_3is ofTEXTtype with valueHello SQLiteandcolumn_4is ofBLOBtype with valueABC.
- This code inserts a row into
Helpful links
More of Sqlite
- How do I use the SQLite VARCHAR data type?
- How can SQLite and ZFS be used together for software development?
- How do I use the SQLite ZIP VFS to compress a database?
- How can I query a SQLite database for records from yesterday's date?
- How can I get the year from a date in SQLite?
- How do I import data from a SQLite zip file?
- How can I use SQLite with Zabbix?
- How do I use SQLite with Zephyr?
- How do I download and install SQLite zip?
- How do I extract the year from a datetime value in SQLite?
See more codes...