Bootstrap FreeKB - SQLite - Delete or Drop Tables
SQLite - Delete or Drop Tables

Updated:   |  SQLite articles

The drop table command can be used to delete or drop a table. In this example, a table named "foo" is deleted/dropped.

~]$ sqlite3 /path/to/example.db
SQLite version 3.34.1 2021-01-20 14:10:07
Enter ".help" for usage hints.

sqlite> drop table foo;

 

Or like this, as a oneliner command.

~]$ sqlite3 /path/to/example.db "drop table foo"

 

If the table exists and is deleted/dropped, there should be no ouput. If the table does not exist, the following should be displayed.

sqlite> drop table foo;
Error: no such table: foo

 

Assuming the table was successfully deleted/dropped, the .tables command should show that the table no longer exists.

sqlite> .tables
bar

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 1ef02c in the box below so that we can be sure you are a human.