In this article, we will see how to install sqlite3 on Ubuntu 22.04 LTS (Jammy Jellyfish). SQLite is a free and open source C-language library that implements a high reliable and fast SQL database engine. It is so small and lightweight that it easily gets built on almost all mobiles phones and computers. Since it gets easily embedded in apps, it is used by millions of devices on various platforms. It is very commonly used as containers to transfer rich contents between number of systems.
Due to its serverless architecture, it is a preferred database engine by many software developers. SQLite3 is the third version of SQLite. One can also easily download and install SQLite3 on almost all the famous platforms. Here we will see how to install sqlite3 on Ubuntu 22.04 LTS based systems.
Also Read: 15 Best Steps to Simplify Your SSH configuration in Linux
a) You should have a running Ubuntu 22.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.
To ensure system security and stability, it is always important to first check for all latest available updates from default Ubuntu repo and install them by using sudo apt update && sudo apt upgrade
command as shown below.
cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade Hit:1 http://in.archive.ubuntu.com/ubuntu jammy InRelease Get:2 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB] Hit:3 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease Get:4 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB] Fetched 229 kB in 4s (60.4 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done 2 packages can be upgraded. Run 'apt list --upgradable' to see them. Reading package lists... Done Building dependency tree... Done Reading state information... Done Calculating upgrade... Done The following packages have been kept back: gjs libgjs0g 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
In the next step, you can install sqlite3 from default Ubuntu repo by running sudo apt install sqlite3
command as shown below. This will download and install the package from repo along with all its required dependencies.
cyberithub@ubuntu:~$ sudo apt install sqlite3 Reading package lists... Done Building dependency tree... Done 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 768 kB of archives. After this operation, 1,873 kB of additional disk space will be used. Get:1 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 sqlite3 amd64 3.37.2-2ubuntu0.3 [768 kB] Fetched 768 kB in 3s (292 kB/s) Selecting previously unselected package sqlite3. (Reading database ... 209908 files and directories currently installed.) Preparing to unpack .../sqlite3_3.37.2-2ubuntu0.3_amd64.deb ... Unpacking sqlite3 (3.37.2-2ubuntu0.3) ... Setting up sqlite3 (3.37.2-2ubuntu0.3) ... Processing triggers for man-db (2.10.2-1) ...
You can check the installed version by using sqlite3 --version
command as shown below.
cyberithub@ubuntu:~$ sqlite3 --version 3.37.2 2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5dalt1
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: 1829 Maintainer: Ubuntu Developers Architecture: amd64 Multi-Arch: foreign Version: 3.37.2-2ubuntu0.3 Depends: libc6 (>= 2.34), libreadline8 (>= 6.0), zlib1g (>= 1:1.2.0), libsqlite3-0 (= 3.37.2-2ubuntu0.3) Suggests: sqlite3-doc ........................................................
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.37.2 2022-01-06 13:25:41 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 department
with two columns in it – dept_id
and dept_name
. We are also going to set all column as not null
to make sure it always contains a value.
sqlite> create table department(dept_id not null, dept_name not null);
Also Read
Now that table is created, let’s insert some values in it. We are going to insert information of two departments as mentioned below:-
a) Department 1:-
Department ID – 103
Department Name – Accounts
b) Department 2:-
Department ID – 104
Department Name – Security
sqlite> insert into department values(103, "Accounts"); sqlite> insert into department values(104, "Security");
After entering records, let’s verify it by running select * from department;
query as shown below.
sqlite> select * from department; 103|Accounts 104|Security
You can also update a value in table. For example, we are updating department name of ID 104
from Security
to Infosec
using update department set dept_name="Infosec" where dept_id=104;
query as shown below.
sqlite> update department set dept_name="Infosec" where dept_id=104;
Then verify the changes by running select * from department;
query as shown below.
sqlite> select * from department; 103|Accounts 104|Infosec
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 department
by using drop table department
command as shown below.
sqlite> drop table department;
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... Done 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, 1,873 kB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 209914 files and directories currently installed.) Removing sqlite3 (3.37.2-2ubuntu0.3) ... Processing triggers for man-db (2.10.2-1) ...
Microsoft Edge is now available for Ubuntu. In this guide, I’ll walk you through the…
Our latest Canonical website rebrand did not just bring the new Vanilla-based frontend, it also…
At Canonical, the work of our teams is strongly embedded in the open source principles…
Welcome to the Ubuntu Weekly Newsletter, Issue 873 for the week of December 29, 2024…
Have WiFi troubles on your Ubuntu 24.04 system? Don’t worry, you’re not alone. WiFi problems…
The following is a post from Mark Shuttleworth on the Ubuntu Discourse instance. For more…