SQLite database introduction
Overview
SQLite is a small, compact, a self-contained, embedded and high reliable database. SQLite is not client-server database. Unlike other SQL databases, SQLite does not have a separate server process.
SQLite is cross platform and supports various platforms like Windows, Linux, Android etc.
Getting started
You can download it for the popular OS platforms at: https://sqlite.org/download.html
SQLite setup is easy. Download the file and extract the files. SQLite is server-less and requires zero configuration. For example, for Windows platform you can download the sqlite-tools and the .dll files and extract to some convenient folder. Say c:\sqlite
sqlite3 command line
The sqlite3 tool is a command line terminal based tool to interact with the SQLite database. You can launch the tool with the following command in the prompt. Open command prompt and cd to the extracted path and verify if its working as shown below:
/> sqlite3
Create database
You can use the sqlite3 command line tool to create a new database file.
$ sqlite3 myDB.db
The database is stored in a cross-platform disk file.
Create table
CREATE TABLE emp ( empno integer PRIMARY KEY, ename text NOT NULL, job text NOT NULL, salary integer NOT NULL, deptid integer NOT NULL );
The .tables command displays the tables in the database.
.tables
You can run simple SQL queries to populate the table and view the data.
INSERT INTO emp VALUES(1,'John Smith','SALESMAN',2500,30); SELECT * FROM emp;