Menu
User

DropVPS Team

Writer: Cooper Reagan

How to reset database sqllite 3 on Ubuntu 25.10

How to reset database sqllite 3 on Ubuntu 25.10

Publication Date

10/26/2025

Category

Articles

Reading Time

3 Min

Table of Contents

SQLite 3 is a lightweight, serverless, and self-contained database engine widely used in web apps, desktop software, and embedded systems. Sometimes you might need to reset or clear your SQLite database — for example, when testing, starting fresh, or fixing corrupted data.

Check SQLite Installation

First, make sure SQLite 3 is installed on your system.
You can verify this with:

sqlite3 --version

If it’s not installed, run:

sudo apt update
sudo apt install sqlite3 -y

Locate Your SQLite Database File

SQLite databases are typically single .db or .sqlite files located inside your application folder.
For example:

/home/user/project/app.db

or

/var/www/html/database.sqlite

You can find your database by using the find command:

sudo find / -name "*.db" 2>/dev/null

Open the Database in SQLite Shell

Once you know the file path, open it using the SQLite command-line tool:

sqlite3 /path/to/your/database.db

You’ll enter the SQLite shell, where you can run SQL commands.

Option 1 — Delete All Data (Keep Tables)

If you want to clear all rows but keep the database schema (tables and structure), run:

DELETE FROM table_name;

For multiple tables, repeat the command for each one.
Or to delete all tables automatically:

PRAGMA writable_schema = 1;
DELETE FROM sqlite_master WHERE type IN ('table', 'index', 'trigger');
PRAGMA writable_schema = 0;
VACUUM;
PRAGMA integrity_check;

This resets your database structure safely.

Exit SQLite when done:

.exit

Option 2 — Drop and Recreate Tables

If you want to recreate tables, you can drop them manually:

rm /path/to/database.db
sqlite3 /path/to/database.db

Inside the SQLite prompt, you can re-create your tables:

CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);
.exit

Now you have a new, clean SQLite database.

Reset Database via Script

If you frequently reset your database during development, you can automate the process with a shell script:

nano reset_db.sh

Add the following:

#!/bin/bash
DB_PATH="/home/user/project/app.db"
rm -f $DB_PATH
sqlite3 $DB_PATH < /home/user/project/schema.sql
echo "SQLite database has been reset."

Make it executable:

Make it executable:

Then run it anytime to reset your database instantly:

./reset_db.sh

Resetting an SQLite 3 database on Ubuntu 25.10 can be done in multiple ways — deleting data, dropping tables, or recreating the entire database. The method you choose depends on whether you want to keep your schema or start completely clean. For high-performance Ubuntu VPS servers ideal for app development, database testing, and automation, visit DropVPS — optimized hosting for developers and teams.

Linux VPS
U
Loading...

Related Posts