How to install SQLite on Ubuntu 17.04

To install SQLite on Ubuntu 17.04

SQLite is a relational database management system available on a C programming library. In contrast to many other database management systems, SQLite is not a client&ndash server database engine. Rather, it is embedded into the end program. In this tutorial, you will be guided through the installation of SQLite on Ubuntu 17.04.

Installing SQLite

Adding the required repository is the most import step to do before you begin with the installation of SQLite on your Ubuntu machine.

root@linuxhelp:~# add-apt-repository ppa:jonathonf/backports
 Backports of various (low impact) packages to Trusty and Xenial
 More info: https://launchpad.net/~jonathonf/+archive/ubuntu/backports
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keybox ' /tmp/tmpl79oftld/pubring.gpg'  created
gpg: /tmp/tmpl79oftld/trustdb.gpg: trustdb created
gpg: key 8CF63AD3F06FC659: public key " Launchpad PPA for J Fernyhough"  imported
gpg: Total number processed: 1
gpg:               imported: 1
OK

Once it is done, update your repository as follows.

root@linuxhelp:~# apt-get update 
Ign:1 http://ppa.launchpad.net/jonathonf/backports/ubuntu zesty InRelease                                      
Ign:2 http://ppa.launchpad.net/jonathonf/backports/ubuntu zesty Release                                        
Hit:3 http://in.archive.ubuntu.com/ubuntu zesty InRelease                     
Ign:4 http://ppa.launchpad.net/jonathonf/backports/ubuntu zesty/main i386 Packages            
Get:5 http://in.archive.ubuntu.com/ubuntu zesty-updates InRelease [89.2 kB]                   
Get:6 http://security.ubuntu.com/ubuntu zesty-security InRelease [89.2 kB]
.
.
.
Get:35 http://security.ubuntu.com/ubuntu zesty-security/universe Translation-en [25.0 kB]                                                                                           
Get:36 http://security.ubuntu.com/ubuntu zesty-security/multiverse i386 Packages [1,980 B]                                                                                          
Get:37 http://security.ubuntu.com/ubuntu zesty-security/multiverse amd64 Packages [1,824 B]                                                                                         
Fetched 869 kB in 12s (67.7 kB/s)                                                                                                                                                   
Reading package lists... Done

Now is the time to install SQLite database. Run the following command for the same purpose.

root@linuxhelp:~# apt-get install sqlite3 -y
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 102 not upgraded.
Need to get 697 kB of archives.
After this operation, 2,355 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu zesty/main amd64 sqlite3 amd64 3.16.2-3 [697 kB]
.
.
.
Preparing to unpack .../sqlite3_3.16.2-3_amd64.deb ...
Unpacking sqlite3 (3.16.2-3) ...
Setting up sqlite3 (3.16.2-3) ...
Processing triggers for man-db (2.7.6.1-2) ...

SQLite has been installed, invoke the following command to enter into SQLite terminal.

root@linuxhelp:~# sqlite3 
SQLite version 3.16.2 2017-01-06 16:32:41
Enter " .help"  for usage hints.
Connected to a transient in-memory database.
Use " .open FILENAME"  to reopen on a persistent database.
Tag : Ubuntu SQLite
FAQ
Q
What is an SQLITE_CORRUPT error?
A
An SQLITE_CORRUPT error is returned when SQLite detects an error in the structure, format, or other control elements of the database file.
SQLite does not corrupt database files without external help. If your application crashes in the middle of an update, your data is safe.
Q
What datatypes does SQLite support?
A
SQLite uses dynamic typing. Content can be stored as INTEGER, REAL, TEXT, BLOB, or as NULL.
Q
Is SQLite threadsafe?
A
1.SQLite is threadsafe.
2.SQLite must be compiled with the SQLITE_THREADSAFE preprocessor macro set to 1.
3.SQLite is threadsafe because it uses mutexes to serialize access to common data structures. However, the work of acquiring and releasing these mutexes will slow SQLite down slightly.
Q
Does SQLite support a BLOB type?
A
SQLite allows you to store BLOB data in any column, even columns that are declared to hold some other type. BLOBs can even be used as PRIMARY KEYs.
Q
What is the maximum size of a VARCHAR in SQLite?
A
SQLite does not enforce the length of a VARCHAR. You can declare a VARCHAR(10) and SQLite will be happy to store a 500-million character string there. And it will keep all 500-million characters intact. Your content is never truncated. SQLite understands the column type of "VARCHAR(N)" to be the same as "TEXT", regardless of the value of N.