Setting Up An Environment
Let’s create a simple table and insert some values into it to demonstrate how to obtain the database size.
Query:
CREATE TABLE Users (
ID INTEGER PRIMARY KEY,
Name TEXT,
Age INTEGER
);
INSERT INTO Users (Name, Age) VALUES ('Alice', 30);
INSERT INTO Users (Name, Age) VALUES ('Bob', 25);
INSERT INTO Users (Name, Age) VALUES ('Charlie', 35);
Output:
How to Get SQLite Database Size
SQLite is a lightweight and serverless SQL database. It is widely used in mobile devices and embedded systems due to its simplicity and efficiency. To understand how to manage SQLite databases efficiently, it is very important to know the Database size in SQLite. In this article, we will learn about different approaches to get the SQLite Database Size.
To retrieve the size of a SQLite database, you can use the PRAGMA statement along with the page_count and page_size properties.
Syntax:
Database Size = page_count * page_size
- page_count is the total number of pages in the database.
- page_size is the size of each page in bytes.