SQLite - Transactional SQL Database Engine
SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
Reference
SQLite - CREATE Database
Basic syntax of SQLitecommand is as follows:
# /usr/bin/sqlite3 DatabaseName.db
SQLite - CREATE Table
Basic syntax of CREATE TABLE statement is as follows:
CREATE TABLE database_name.table_name(
column1 datatype PRIMARY KEY(one or more columns),
column2 datatype,
column3 datatype,
.....
...
.
columnN datatype,
);
SQLite - DROP Table
Basic syntax of DROP TABLE statement is as follows. You can optionally specify database name along with table name as follows:
DROP TABLE database_name.table_name;
SQLite - INSERT Query
There are two basic syntaxes of INSERT INTO statement as follows:
INSERT INTO TABLE_NAME [(column1, column2, column3,...columnN)]
VALUES (value1, value2, value3,...valueN);
Here, column1, column2,…columnN are the names of the columns in the table into which you want to insert data.
You may not need to specify the column(s) name in the SQLite query if you are adding values for all the columns of the table. But make sure the order of the values is in the same order as the columns in the table. The SQLite INSERT INTO syntax would be as follows:
INSERT INTO TABLE_NAME VALUES (value1,value2,value3,...valueN);
SQLite - SELECT Query
The basic syntax of SQLite SELECT statement is as follows:
SELECT column1, column2, columnN FROM table_name;
Here, column1, column2…are the fields of a table, whose values you want to fetch. If you want to fetch all the fields available in the field then you can use following syntax:
SELECT * FROM table_name;
You can list down complete information about a table as follows:
SELECT sql FROM sqlite_master WHERE type = 'table' AND tbl_name = 'TableName';
SQLite - UPDATE Query
The basic syntax of UPDATE query with WHERE clause is as follows:
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];
SQLite - DELETE Query
The basic syntax of DELETE query with WHERE clause is as follows:
DELETE FROM table_name
WHERE [condition];
If you want to DELETE all the records from a table, you do not need to use WHERE clause with DELETE query, which would be as follows:
DELETE FROM table_name;
SQLite - LIKE Clause
The basic syntax of % and _ is as follows:
SELECT FROM table_name
WHERE column LIKE 'XXXX%'
or
SELECT FROM table_name
WHERE column LIKE '%XXXX%'
or
SELECT FROM table_name
WHERE column LIKE 'XXXX_'
or
SELECT FROM table_name
WHERE column LIKE '_XXXX'
or
SELECT FROM table_name
WHERE column LIKE '_XXXX_'
You can combine N number of conditions using AND or OR operators. Here XXXX could be any numeric or string value.