Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
Introduction to SQLite
Next article icon

Introduction to SQLite

Last Updated : 23 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

SQLite is a highly efficient, serverless, and self-contained SQL database engine that stands out for its simplicity and ease of integration. Designed to be embedded within applications, SQLite eliminates the need for separate database server processes and complex configurations.

In this article, We will learn about SQLite in detail.

What is SQLite?

  • SQLite is a lightweight, serverless, self-contained, and highly reliable SQL database engine. It is widely used due to its simplicity, ease of setup and zero-configuration nature.
  • SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. It is a popular choice as an embedded database for local/client storage in application software such as web browsers. It is also used in many other applications that need a lightweight, embedded database.
  • SQLite is ACID-compliant and implements most of the SQL standards, using a dynamically and weakly typed SQL syntax that does not guarantee domain integrity.
  • To use SQLite in a C/C++ program, you can use the SQLite3 API, which provides a lightweight, simple, self-contained, high-reliability, full-featured, and SQL database engine. The API is implemented as a library of C functions that can be called from your program.
  • One of the main benefits of using SQLite is that it is very easy to get started with. To create a new database in SQLite, you simply need to create a new file on your filesystem and connect to it using the SQLite3 API.
  • For example, in C:
C
#include <sqlite3.h>  int main(int argc, char **argv) {   sqlite3 *db;   int rc;    rc = sqlite3_open("test.db", &db);   if (rc != SQLITE_OK) {     // error handling   }    // do something with the database    sqlite3_close(db);   return 0; } 

History of SQLite

  • SQLite was created in the year 2000 by D. Richard Hipp, who continues to lead the development of the software today.
  • SQLite was designed to be a lightweight and simple database engine that could be easily embedded into other applications.
  • It was created as an alternative to more complex and heavyweight database engines, such as MySQL and PostgreSQL.
  • Over the years, SQLite has gained widespread adoption and is now one of the most widely used database engines in the world. It is used in many applications, including web browsers, mobile phones, and a wide variety of other software.
  • SQLite is an open-source software project, and the source code is available under the terms of the SQLite license which is a permissive, public domain-like license.
  • This has contributed to its widespread adoption, as developers are free to use and modify the source code as they see fit.

Why Use SQLite?

There are several reasons why you might choose to use SQLite in your project:

  1. Ease of use: SQLite is very easy to get started with, as it requires no setup or configuration. You can simply include the library in your project and start using it.
  2. Embeddability: SQLite is designed to be embedded into other applications. It is a self-contained, serverless database engine, which means you can include it in your application without the need for a separate database server.
  3. Lightweight: SQLite is a very lightweight database engine, with a small library size (typically less than 1MB). This makes it well-suited for use in applications where the database is embedded directly into the application binary, such as mobile apps.
  4. Serverless: As mentioned earlier, SQLite is a serverless database engine, which means there is no need to set up and maintain a separate database server process. This makes it easy to deploy and manage, as there are no additional dependencies to worry about.
  5. Cross-platform: SQLite is available on many platforms, including Linux, macOS, and Windows, making it a good choice for cross-platform development.
  6. Standalone: SQLite stores all of the data in a single file on the filesystem, which makes it easy to copy or backup the database.
  7. High reliability: SQLite has been widely tested and used in production systems for many years, and has a reputation for being a reliable and robust database engine.

An easy way to get started with SQLite

Because SQLite is an embedded database, you actually don't need to 'download' it in the same way that you would download MySQL or PostgreSQL for example. You can create and interact with SQLite databases using a range of tools.

An easy way to get started would be to:

  1. Download an example SQLite dataset, like the Sakila dataset, available here on GitHub
  2. Download a GUI program to access the database, like Beekeeper Studio, or DBeaver
  3. Double-click the '.db' file to open it.
  4. Using these tools, you can navigate your SQLite file in a spreadsheet-like way.

Installation on Windows: 

If you want to install the official SQLite binary and interact with the database using the terminal, you can follow these directions:

1. Visit the official website of SQLite to download the zip file. 

2. Download that zip file. 

3. Create a folder in C or D ( wherever you want ) for storing SQLite by expanding the zip file. 

4. Open the command prompt and set the path for the location of the SQLite folder given in the previous step. After that write "sqlite3" and press enter. You can also directly open the .exe file from the folder where you have stored the SQLite whole thing. After clicking on the selected .exe file it will open SQLite application Installation on Linux: Open Terminal, type this command, and enter the password

sudo apt-get install sqlite3 libsqlite3-dev

sqlite3 It will automatically install and once it asks Do you want to continue (Y/N) type Y and press enter. After successful installation, we can check it by command sqlite3. installation of sqlite3

Features of SQLite

  1. The transactions follow ACID properties i.e. atomicity, consistency, isolation, and durability even after system crashes and power failures.
  2. The configuration process is very easy, no setup or administration is needed.
  3. All the features of SQL are implemented in it with some additional features like partial indexes, indexes on expressions, JSON, and common table expressions.
  4. Sometimes it is faster than the direct file system I/O.
  5. It supports terabyte-sized databases and gigabyte-sized strings and blobs.
  6. Almost all OS supports SQLite like Android, BSD, iOS, Linux, Mac, Solaris, VxWorks, and Windows (Win32, WinCE, etc. It is very much easy to port to other systems.
  7. A complete database can be stored in a single cross-platform disk file.

Applications of SQLite

  1. Due to its small code print and efficient usage of memory, it is the popular choice for the database engine in cell phones, PDAs, MP3 players, set-top boxes, and other electronic gadgets.
  2. It is used as an alternative for open to writing XML, JSON, CSV, or some proprietary format into disk files used by the application.
  3. As it has no complication for configuration and easily stores file in an ordinary disk file, so it can be used as a database for small to medium sized websites.
  4. It is faster and accessible through a wide variety of third-party tools, so it has great applications in different software platforms.

SQLite Commands In SQLite, there are several dot commands which do not end with a semicolon(;). Here are all commands and their description:

SQLite Commands

In SQLite, DDL (Data Definition Language) is used to create and modify database objects such as tables, indices, and views. Some examples of DDL statements in SQLite are:

  • CREATE TABLE: creates a new table in the database.
  • ALTER TABLE: modifies an existing table in the database.
  • DROP TABLE: deletes a table from the database.
  • CREATE INDEX: creates a new index on a table.
  • DROP INDEX: deletes an index from a table.

DML (Data Modification Language) is used to modify the data stored in the database. Some examples of DML statements in SQLite are:

  • INSERT INTO: inserts a new row into a table.
  • UPDATE: updates the data in one or more rows of a table.
  • DELETE FROM: deletes one or more rows from a table

DQL (Data Query Language) is used to retrieve data from the database. Some examples of DQL statements in SQLite are:

  • SELECT: retrieves data from one or more tables in the database.
  • JOIN: retrieves data from multiple tables based on a common field.
  • GROUP BY: groups the results of a query by one or more fields.
  • HAVING: filters the results of a query based on a condition

Limitations of SQLite

  • Limited concurrency: SQLite uses file-based locking to control access to the database, which can lead to performance issues when multiple clients are trying to read and write to the database simultaneously. This makes it less suitable for use in highly concurrent systems.
  • No support for stored procedures: SQLite does not support stored procedures, which are pre-compiled SQL statements that can be executed on the server. This means that all SQL code must be sent to the server and compiled at runtime, which can be less efficient than using stored procedures.
  • No support for triggers: SQLite does not support triggers, which are database actions that are automatically triggered by specified events (such as the insertion of a row into a table). This means that you have to manually implement any logic that needs to be triggered by specific events.
  • Limited support for data types: SQLite has a relatively small set of data types compared to other database engines. It does not support many of the more advanced data types, such as arrays and JSON, that are available in other databases.
  • Limited scalability: SQLite is not designed to be a high-concurrency, high-transaction-rate database engine. It is more suited for use in smaller-scale, low-concurrency systems, and may not be able to scale to handle very large amounts of data or very high levels of concurrency.

Conclusion

SQLite's lightweight nature and ease of use make it a versatile option for developers needing an embedded database solution. Its self-contained structure and ACID compliance provide reliability and simplicity for handling transactions.


Next Article
Introduction to SQLite

S

Surya Priy
Improve
Article Tags :
  • Misc
  • Technical Scripter
  • SQL
  • Databases
Practice Tags :
  • Misc

Similar Reads

    SQLite Intersect Operator
    SQLite is a server-less database engine written in C programming language. It is developed by D. Richard Hipp in the year 2000. The main moto for developing SQLite is escaping complex database engines like MYSQL. It has become one of the most popular database engines as we use it in Television, Mobi
    5 min read
    Top 50 SQLite Interview Questions for 2024
    In this interview preparation blog post, we’ll explore some of the most common SQLite interview questions that can help you showcase your knowledge and skills on SQLite effectively. From understanding its fundamental concepts to tackling more advanced queries and optimization techniques, this guide
    15+ min read
    SQLite Joins
    SQLite is a server-less database engine and it is written in C programming language. It is developed by D. Richard Hipp in the year 2000. The main motive for developing SQLite is to overcome the use of complex database engines like MySQL etc. It has become one of the most popularly used database eng
    5 min read
    SQL Interview Questions
    Are you preparing for a SQL interview? SQL is a standard database language used for accessing and manipulating data in databases. It stands for Structured Query Language and was developed by IBM in the 1970's, SQL allows us to create, read, update, and delete data with simple yet effective commands.
    15+ min read
    SQLite UNIQUE Constraint
    SQLite is a lightweight relational database management system (RDBMS). It requires minimal configuration and it is self-contained. It is an embedded database written in C language. It operates a server-less, file-based database engine making it a good fit for mobile applications and simple desktop a
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences