Search This Blog

SQLite Tutorial

 


SQLite Tutorial

SQLite is a popular relational database technology that is contained in a C programming library. SQLite is a compact library that reads and writes directly to ordinary disk files. It is, in essence, a serverless SQL database.

Our tutorial will start with the basics of SQLite such as how to retrieve and manipulate data. Then we will move to the more advanced topics such as how to create tables. We will conclude with a review of the functions that are proprietary to SQLite.

With this tutorial, you should be on your way to becoming proficient in SQLite and its programming language.

Prerequisites

There are no prequisities for this SQLite tutorial. You should be able to easily understand this tutorial and learn the basic concepts of MySQL as you progress to the more advanced topics.

Now, let's get started!

Start Tutorial

Or jump directly to a topic in SQLite:

SQLite Functions

Functions - AlphabeticalSQLite Functions listed alphabetically
Functions - CategorySQLite Functions listed by category

SQLite Keys, Constraints and Indexes

Primary KeysCreate, add, and drop primary keys
Foreign KeysCreate foreign keys
IndexesCreate, drop, and rename indexes (Performance tuning)
Unique ConstraintsCreate, add, and drop unique constraints
ANALYZE CommandGather statistical information about tables and indexes (used by query optimizer)

SQLite Database Administration

ATTACH DATABASEAttach another database file to your connection
DETACH DATABASEDetach an attached database from your connection
VacuumReclaim unused space in database
Auto_VacuumProcess that automatically reclaims unused space in database

SQLite Programming

Literals (Constants)String, number, date, time, boolean literals
Comments within SQLHow to create comments within your SQL statement

SQLite Comparison Operators

Comparison OperatorsOperators such as =, <>, !=, >, <, and so on

SQLite Query Types

SELECT StatementRetrieve records from a table
SELECT LIMIT StatementRetrieve records from a table and limit results
INSERT StatementInsert records into a table
UPDATE StatementUpdate records in a table
DELETE StatementDelete records from a table
TRUNCATE TABLE StatementDelete all records from a table (with optimizer)
UNION OperatorCombine 2 result sets (removes duplicates)
UNION ALL OperatorCombine 2 result sets (includes duplicates)
INTERSECT OperatorIntersection of 2 result sets
EXCEPT OperatorResult set of one minus the result set of another
SubqueriesA query within a query

SQLite Joins

JOIN TablesInner and Outer joins

SQLite Aliases

ALIASESCreate a temporary name for a column or table

SQLite Clauses

DISTINCT ClauseRetrieve unique records
FROM ClauseList tables and join information
WHERE ClauseFilter results
ORDER BY ClauseSort query results
GROUP BY ClauseGroup by one or more columns
HAVING ClauseRestrict the groups of returned rows

SQLite SQL Functions

COUNT FunctionReturn the count of an expression
SUM FunctionReturn the sum of an expression
MIN FunctionReturn the min of an expression
MAX FunctionReturn the max of an expression
AVG FunctionReturn the average of an expression

SQLite Conditions

AND Condition2 or more conditions to be met
OR ConditionAny one of the conditions are met
AND and ORCombine AND and OR conditions
LIKE ConditionUse wildcards in a WHERE clause
IN ConditionAlternative to multiple OR conditions
NOT ConditionNegate a condition
IS NULL ConditionTest for a NULL value
IS NOT NULL ConditionTest for a NOT NULL value
BETWEEN ConditionRetrieve within a range (inclusive)
EXISTS ConditionCondition is met if subquery returns at least one row

SQLite Tables and Views

CREATE TABLECreate a table
CREATE TABLE ASCreate a table from another table's definition and data
ALTER TABLEAdd, modify, delete columns in a table; rename a table
DROP TABLEDelete a table
VIEWVirtual tables (views of other tables)

SQLite Data Types

Data TypesData Types in SQLite

SQLite System Tables

SQLite System TablesSQLite system tables and descriptions

No comments:

Post a Comment

SQLite: Foreign Keys

  SQLite:   Foreign Keys This SQLite tutorial explains how to use   Foreign Keys   in SQLite with syntax and examples. What is a Foreign Key...