11 C
Texas
angeloma
Senior Writer and partner

How to install SQLite on Ubuntu 20.04 / 18.04?

There is a wide variety of database managers today. Of all of them, MySQL continues to be the most prominent within open source. On the other hand, PostgreSQL is also a robust alternative that has a special share in market projects. Maybe being less popular but just as robust we have SQLite. So today I’m going to show you how to install SQLite on Ubuntu 20.04  / 18.04.

SQLite is a small, reliable and very fast database engine. It is one of the most efficient database engines in the world. In part, thanks to that made in C Language which makes it very efficient in managing the resources of the system.

In like manner, the development of SQLite is so important that many major companies participate in it. This is done through the SQLite Consortium. In addition, all the code is available to be downloaded, viewed and reused for being open source.

So, let us start.

Install SQLite on Ubuntu 20.04 / 18.04

- Advertisement -

SQLite is a very light and powerful program. It will not take long. In addition, to simplify the whole process, SQLite is available in the official repositories of Ubuntu 18.04 and Linux Mint 19.

So, first, you need to update the APT cache.

:~$ sudo apt update

1.- Update the repositories cache
1.- Update the repositories cache

Then, you can search the repositories for SQLite-related packages.

:~$ sudo apt-cache search sqlite

2.- SQLite packages
2.- SQLite packages

Then you can start installing SQLite. To do this, run the following command:

:~$ sudo apt install sqlite3

3.- Install SQLite on Ubuntu 20.04 / 18.04
3.- Install SQLite on Ubuntu 20.04 / 18.04

After that, you can check the installed version by running the following command.

:~$ sqlite3 --version

4.- SQLite version
4.- SQLite version

And that’s it.

The first steps with SQLite

Now, it is convenient that I show you the first steps with SQLite. Let us create a test database.

:~$ sqlite3 example.db

5.- Creating a new database with SQLite
5.- Creating a new database with SQLite

In the SQL language, databases are composed of Tables. So, let us create an example table named “Student”.

sqlite> CREATE TABLE Student
               (
               Id VARCHAR(25) NOT NULL,
               Name VARCHAR(25) NOT NULL,
               Last_Name VARCHAR(25) NOT NULL,
               Age INTEGER(2) NOT NULL,
               CONSTRAINT pk_Student PRIMARY KEY (Id)
               );

6.- Creating a new table
6.- Creating a new table

In the previous image, it is shown that we have created a table with several fields and where the Id field is the primary key. This is SQL language so you have to learn it in order to use SQLite correctly.

After that, you can check that the table was created.

sqlite> .tables

7.- Show the table
7.- Show the table

Then, you can insert some values on the newly created table.

sqlite> INSERT INTO Student (Id, Name, Last_Name, Age) VALUES ('Xy01','Jon','Snow',18);

8.- Insert some data
8.- Insert some data

Finally, use the Select command to show the data inserted.

sqlite> SELECT * FROM Student;

9.- Show some data
9.- Show some data

Now, you can use SQLite to make projects. Type .exit to close SQLite shell.

Bonus: How to install SQLite Browser

As a bonus, I will teach you how to install the SQLite Browser which is a front-end for SQLite. It is quite complete and will help with data visualization and data management. So, run these commands:

:~$ sudo add-apt-repository -y ppa:linuxgndu/sqlitebrowser
:~$ sudo apt update
:~$ sudo apt install sqlitebrowser

10.- Install SQLitebrowser
10.- Install SQLite browser

Next, open it from the main menu.

11.- SQLite browser
11.- SQLite browser

For example, you can open the database previously created. Click on the OpenDatabase button and search for it.

12.- SQLite browser
12.- SQLite browser

After that, you can browse the data.

13.- Browse the data
13.- Browse the data

Enjoy it.

Conclusion

SQLite is a great database application and if we learn to use it, it would be a great help for our projects. Installing it is very easy and gives us a lot of work possibilities. In addition, the SQLite Browser makes the workflow too easy.

Please share this post with your friends.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

4 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article