Getting started with SQLite

Introduction

SQLite is an open-source database that is lightweight compared to other databases. It is really efficient in terms of performance as the entire database is packaged and stored as a single file within our file system. It has most of the standard SQL features like transactions, support for triggers, views, and primary and foreign key constraints. It is widely used, and most of Android applications use SQLite as the database. The entire source code for the database is publicly available.

Features of SQLite

Some of the important features of SQLite are 

  1. Support all ACID properties
  2. No configuration needed nor no external dependencies are needed
  3. Database is lightweight and performance is better than standard databases
  4. Database is available as a single file on a disk and is platform-independent.
  5. Its open source and even source implement in C is publicly available
  6. Simple and easy to use and supports large databases

Download and getting started with SQLite

To start with SQLite, we need to download the latest version of the SQLite software. The current stable version of SQLite is 3.7.9, which can be downloaded at the following location: http://www.sqlite.org/download.html. Once you download the database and unzip it, you can start accessing the database using the command line shell, as seen below.

sqlite

Once you enter sqlite3.exe, you can see the details about SQLite, and you are all set to use it.

sqlitesoftware

How to Create a Database in SQLite?

By default, there will be a Main database, and all new tables created will go to the Main database.

Type. databases on the SQLite command shell to get a list of databases.

You can type a query as seen below to create a table that will go into the main database by default.

sqlite exe

You can insert records and also view them as seen below.

sqlite dynamic

SQLite uses dynamic typing. Even though we define types for columns, but still any type of data can be stored in any column. Types are resolved based on data and there is no type safety.

Backup\ Loading of Database

Use .backup command as seen below to take a backup of Main db.

main db

This is brief overview of SQLite and this explains how easy it is to work with SQLite. For more details, go through SQLiteHome Page.


Similar Articles