How to install SQLite on Debian 11

SQLite is a relational database that uses SQL for data management. One of its main features is that it is quite fast and that is thanks to the fact that it is built in C Language.

As expected, SQLite is open source and that is why its source code is public domain, and you can examine it for any purpose.

It is currently used in many applications, including some developed as high-level projects, especially in mobile or portable projects.

The latter makes it very popular among developers worldwide.

Why is SQLite so popular?

SQLite is a lightweight solution that can be done on almost anything that supports C and persistent file storage. Being lightweight, it is not only available for large projects, but also for smaller projects or where there are not enough resources.

Another aspect to keep in mind is that SQLite databases are simple files. Therefore, they are very portable and easy to back up. This makes it ideal for portable applications or mobile platforms.

So, fast, cross-platform, open source, reliable, and portable are the reasons why SQLite is so popular among developers.

Install SQLite on Debian 11

SQLite is present in the official Debian 11 repositories. This makes installation easy to tackle.

First, open a terminal or from an SSH session and make sure the system is installed.

sudo apt update
sudo apt upgrade

After this, you can install SQLite by running the following command:

sudo apt install sqlite3

You are done. Now you can verify the installed version with the command:

sqlite3 --version

Sample output:

3.34.1 2021-01-20 14:10:07 10e20c0b43500cfb9bbc0eaa061c57514f715d87238f4d835880cd846b9ealt1

Optional: Get the latest stable version of SQLite

The previous method is possibly the easiest, comfortable and safe way to get SQLite in Debian 11, but there is another one that provides us with the latest stable version.

To do so, download it from the [SQLite] website (https://www.sqlite.org/download.html) or using wget.

wget https://www.sqlite.org/2022/sqlite-tools-linux-x86-3380500.zip

Then, unzip it using unzip

unzip sqlite-tools-linux-x86-3380500.zip

In the resulting folder, you will have the SQLite binary that you can run in the terminal.

./sqlite3 --version

SQLite at a glance

SQLite is managed somewhat differently than other SQL-based solutions.

Databases in SQLite are created as a file. So to create one, you just need to run.

sqlite3 [database-name]

For example:

sqlite3 atechtown.db

At once, you will be able to start using it.

For example, create a table:

sqlite> CREATE TABLE atechtown
               (
               Id VARCHAR(25) NOT NULL,
               FirstN VARCHAR(25) NOT NULL,
               LastN VARCHAR(25) NOT NULL,
               Age INTEGER(2) NOT NULL,
               CONSTRAINT pk_Student PRIMARY KEY (Id)
               );

If you’d like, you can check the created table:

sqlite> .tables
atechtown

And you can add data to this new table.

sqlite> INSERT INTO atechtown (Id, FirstN, LastN, Age) VALUES ('at01','Lio','Messi',30);

Finally, query the data:

sqlite> SELECT * FROM atechtown;
Using SQLite on Debian 11
Using SQLite on Debian 11

Conclusion

In this post, you learned how to install SQLite in Debian 11. Besides this, you took your first steps with it.

I hope you liked this post, and you can share it with your friends.

Leave a Comment

Your email address will not be published.