/    /  SQLiteDB – Drop Table

SQLiteDB – Drop Table:

In SQLite, you can drop a table using the DROP TABLE command. Please make note that once the table is dropped, the associated data, indexes, triggers everything will be deleted from the database.

Syntax:

DROP TABLE [IF EXISTS] [schema_name.] table_name;

Example:

sqlite> CREATE TABLE STUDENTS (

cust_id integer PRIMARY KEY,

first_name text not null,

last_name text not null,

age integer not null,

Gender text not null,

City   text not null

);

sqlite> .tables

CUSTOMERS STUDENTS

sqlite> drop table students;

sqlite> .tables

CUSTOMERS

Generally, when we are dropping a table we need to check about the primary key and foreign key constraints. If there are such dependencies, the table cannot be dropped. So, in that case we need to disable the foreign key constraints and then need to give the drop command.