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 troubleshoot a near syntax error when using SQLite?
- How can SQLite and ZFS be used together for software development?
- How do I use SQLite keywords to query a database?
- How do I use the SQLite ZIP VFS to compress a database?
- How do I call sqlitepcl.raw.setprovider() when using SQLite?
- How to configure SQLite with XAMPP on Windows?
- How do I use SQLite with Visual Studio?
- How do I use SQLite transactions?
- How do I write a SQLite query?
- How do I resolve an error "no such column" when using SQLite?
See more codes...