How to check if a table already exists in SQLite?

Run this query to check:

SELECT name FROM sqlite_master WHERE type='table' AND name='table_name';

Before creating for dropping a table, use IF EXIST when you’re not sure:

  • To create a table:
CREATE TABLE IF NOT EXISTS table_name (table_definition);
  • To drop a table:
DROP TABLE IF EXISTS table_name;

Need a good GUI tool for SQLite? Check out TablePlus. It’s native, beautiful, and available for free.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS

TablePlus GUI Tool SQLite