In this article, we will see how to install sqlite3 on Ubuntu 20.04 LTS (Focal Fossa). SQLite3 is the third version of SQLite, which is a widely used software library that provides a lightweight, disk-based database. SQLite3 does not require a separate server process or system, unlike traditional database systems like MySQL or PostgreSQL. It is fully self-contained, serverless, and operates in a zero-configuration mode, making it an ideal choice for applications requiring a simple, efficient, and reliable database system.
Also Read: How to Install Konsole terminal emulator on Ubuntu 20.04
a) You should have a running Ubuntu 20.04 LTS
Server.
b) You should have sudo
or root
access to run privileged commands.
c) You should have apt
or apt-get
utility available in your Server.
As always, before installing any new packages, let’s check for all the available updates and install them by using sudo apt update && sudo apt upgrade
command as shown below.
cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade
[sudo] password for cyberithub:
Hit:1 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:4 http://ppa.launchpad.net/gencfsm/ppa/ubuntu focal InRelease
Hit:5 https://d3nt0h4h6pmmc4.cloudfront.net/ubuntu focal InRelease
Hit:6 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:7 http://ppa.launchpad.net/juju/stable/ubuntu focal InRelease
Ign:8 https://pkg.jenkins.io/debian-stable binary/ InRelease
Hit:9 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:10 https://pkg.jenkins.io/debian-stable binary/ Release
Hit:11 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit:13 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal InRelease
Hit:14 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu focal InRelease
Hit:15 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 InRelease
Hit:16 https://download.sublimetext.com apt/stable/ InRelease
..............................................................
Then to install sqlite3, use sudo apt install sqlite3
command as shown below. This will download and install the package from default ubuntu repo along with all its dependencies.
cyberithub@ubuntu:~$ sudo apt install sqlite3 [sudo] password for cyberithub: Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: sqlite3-doc The following NEW packages will be installed: sqlite3 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. Need to get 0 B/860 kB of archives. After this operation, 2,803 kB of additional disk space will be used. Selecting previously unselected package sqlite3. (Reading database ... 295643 files and directories currently installed.) Preparing to unpack .../sqlite3_3.31.1-4ubuntu0.5_amd64.deb ... Unpacking sqlite3 (3.31.1-4ubuntu0.5) ... Setting up sqlite3 (3.31.1-4ubuntu0.5) ... Processing triggers for man-db (2.9.1-1) ...
Also Read
You can check the installed version by using sqlite3 --version
command as shown below.
cyberithub@ubuntu:~$ sqlite3 --version 3.31.1 2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837balt1
You can also verify the installation status by running dpkg -s sqlite3
command as shown below. To know more about dpkg
command, check 21+ Practical dpkg Command Examples for Linux Beginners.
cyberithub@ubuntu:~$ dpkg -s sqlite3 Package: sqlite3 Status: install ok installed Priority: optional Section: database Installed-Size: 2737 Maintainer: Ubuntu Developers Architecture: amd64 Multi-Arch: foreign Version: 3.31.1-4ubuntu0.5 Depends: libc6 (>= 2.29), libreadline8 (>= 6.0), zlib1g (>= 1:1.2.0), libsqlite3-0 (= 3.31.1-4ubuntu0.5) Suggests: sqlite3-doc Description: Command line interface for SQLite 3 SQLite is a C library that implements an SQL database engine. Programs that link with the SQLite library can have SQL database access without running a separate RDBMS process. Homepage: https://www.sqlite.org/ Original-Maintainer: Laszlo Boszormenyi (GCS)
To create a database, you can simply run sqlite3
command. For example, here we are creating a database called cyberithub.db
using sqlite3 cyberithub.db
query as shown below.
cyberithub@ubuntu:~$ sqlite3 cyberithub.db SQLite version 3.31.1 2020-01-27 19:55:54 Enter ".help" for usage hints. sqlite>
To create a table, you can use create table query. For our demo purpose, we are going to create a table called employee
with three columns in it – employee_id
, employee_name
and department
. We are also going to set all column as not null
to make sure it always contains a value.
sqlite> create table employee(employee_id not null, employee_name not null, department not null);
Now that table is created, let’s insert some values in it. We are going to insert information of two employees as mentioned below:-
a) Employee 1:-
Name – John Kennedy
Employee ID – 675898
Department – Marketing
b) Employee 2:-
Name – Andrew Walton
Employee ID – 875398
Department – Accounts
sqlite> insert into employee values(675898, "John Kennedy", "Marketing"); sqlite> insert into employee values(875398, "Andrew Walton", "Accounts");
After entering records, let’s verify it by running select * from employee;
query as shown below.
sqlite> select * from employee;
675898|John Kennedy|Marketing
875398|Andrew Walton|Accounts
You can also update a value in table. For example, we are updating department of an employee with Employee ID 875398
from Accounts
to Finance
by using update employee set department="Finance" where employee_id=875398;
query as shown below.
sqlite> update employee set department="Finance" where employee_id=875398;
Then verify the changes by running select * from employee;
query as shown below.
sqlite> select * from employee;
675898|John Kennedy|Marketing
875398|Andrew Walton|Finance
If you are looking to delete a table then you can delete it by using drop table
syntax. For example, here we are deleting table employee
by using drop table employee
command as shown below.
sqlite> drop table employee;
Once you are done using sqlite3, you can also choose to uninstall sqlite3
from your system by using sudo apt remove sqlite3
command as shown below.
cyberithub@ubuntu:~$ sudo apt remove sqlite3 Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: sqlite3 0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded. After this operation, 2,803 kB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 295649 files and directories currently installed.) Removing sqlite3 (3.31.1-4ubuntu0.5) ... Processing triggers for man-db (2.9.1-1) ...
2024 was the GenAI year. With new and more performant LLMs and a higher number…
Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…
Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…
At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…
I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…
Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…