0 votes
1 view
in SQL by (20.3k points)

What is the command to drop all tables in SQLite?

Similarly, I'd like to drop all indexes.

1 Answer

0 votes
by (40.3k points)

While it is true that there is no DROP ALL TABLES command you can use the following set of commands.

PRAGMA writable_schema = 1;

delete from sqlite_master where type in ('table', 'index', 'trigger');

PRAGMA writable_schema = 0;

you then want to recover the deleted space with

VACUUM;

and a good test to make sure everything is ok

PRAGMA INTEGRITY_CHECK;

Note: These commands have the potential to corrupt your database, so make sure you have a backup

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 12, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...