How to Install SQLite3 in Ubuntu / Linux Mint

SQlite is an Embedded Relational Database Management System. SQlite does not require a server to run unlike mysql or other popular dbms.

To install Sqlite3 in Ubuntu / Linux Mint issue the following commands

This will work for Ubuntu 14.04 and above

sudo apt-get update
sudo apt-get install sqlite3 libsqlite3-dev


Basic Command Line Usage:

1. Create a new Database

aman@vostro:~$ sqlite3 databasename.db
SQLite version 3.11.0 2016-02-15 17:29:24
Enter ".help" for usage hints.
sqlite> 

 

2. Create a table and insert values in it.

sqlite> CREATE TABLE student (id integer, firstname varchar(30), lastname varchar(20), country varchar(20));
sqlite> INSERT INTO STUDENT VALUES (1, "James", "Hetfield", "USA");
sqlite> INSERT INTO STUDENT VALUES (2, "Kirk", "Hammet", "USA");

3. View all table entries

sqlite> select * from student;
1|James|Hetfield|USA
2|Kirk|Hammet|USA

4. Exit Sqlite3

sqlite> .exit

5. Open Existing Database

aman@vostro:~$ sqlite3 databasename.db

Leave a Reply

Your email address will not be published.