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
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
Then, you can search the repositories for SQLite-related packages.
:~$ sudo apt-cache search sqlite
Then you can start installing SQLite. To do this, run the following command:
:~$ sudo apt install sqlite3
After that, you can check the installed version by running the following command.
:~$ sqlite3 --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
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) );
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.
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);
Finally, use the Select command to show the data inserted.
sqlite> SELECT * FROM Student;
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
Next, open it from the main menu.
For example, you can open the database previously created. Click on the OpenDatabase button and search for it.
After that, you can browse the data.
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.