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 SQLite with Zephyr?
- How do I use the SQLite ZIP VFS to compress a database?
- How do I call sqlitepcl.raw.setprovider() when using SQLite?
- How can I use SQLite with WPF?
- How do I use SQLite xfilter to filter data?
- How can I use SQLite with Zabbix?
- How do I extract the year from a datetime value in SQLite?
- How can I use the XOR operator in a SQLite query?
- How can I get the year from a date in SQLite?
- How do I generate XML output from a SQLite database?
See more codes...