Download our e-book of Introduction To Python
Neha Kumawat
3 years ago
DROP TABLE table_name;
sqlite> CREATE TABLE CRICKETERS (
First_Name VARCHAR(255), Last_Name VARCHAR(255), Age int,
Place_Of_Birth VARCHAR(255), Country VARCHAR(255)
);
sqlite> CREATE TABLE EMPLOYEE(
FIRST_NAME CHAR(20) NOT NULL, LAST_NAME CHAR(20), AGE INT,
SEX CHAR(1), INCOME FLOAT
);
sqlite>
sqlite> .tables
CRICKETERS EMPLOYEE
sqlite>
sqlite> DROP table employee;
sqlite>
sqlite> .tables
CRICKETERS
sqlite>
sqlite> DROP table employee;
Error: no such table: employee
sqlite>
sqlite> DROP table IF EXISTS employee;
sqlite>
import sqlite3
#Connecting to sqlite
conn = sqlite3.connect('example.db')
#Creating a cursor object using the cursor() method
cursor = conn.cursor()
#Doping EMPLOYEE table if already exists
cursor.execute("DROP TABLE emp")
print("Table dropped... ")
#Commit your changes in the database
conn.commit()
#Closing the connection
conn.close()
Table dropped...