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_name
with four columns of different data types:column_1
ofINTEGER
type,column_2
ofREAL
type,column_3
ofTEXT
type andcolumn_4
ofBLOB
type.
- 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_name
with different data types:column_1
is ofINTEGER
type with value1
,column_2
is ofREAL
type with value3.14
,column_3
is ofTEXT
type with valueHello SQLite
andcolumn_4
is ofBLOB
type with valueABC
.
- This code inserts a row into
Helpful links
More of Sqlite
- How can I use SQLite with Zabbix?
- How do I show the databases in SQLite?
- How do I resolve an error "no such column" when using SQLite?
- How to configure SQLite with XAMPP on Windows?
- How can I use SQLite with Xamarin and C# to develop an Android app?
- How do I use SQLite with Visual Studio?
- How do I use the SQLite YEAR function?
- How do I install and use SQLite on Ubuntu?
- How do I download and install SQLite zip?
- How do I use the SQLite sequence feature?
See more codes...