---
# System prepended metadata

title: SQL Interview Question

---

# SQL Interview Question 

**Difference Between Drop, Delete and Truncate Command**

*  Drop- DDL command to delete the table including its schema and structure. Do not get confused with DROP COLUMN and DROP. They both are different. DROP deletes the entire table. DROP COLUMN is a keyword used under ALTER Command to delete a column
 
*  Truncate DDL- delete all the entries of table in one go but it preserves the structure of table in the database. It doesn't allow where clause
 
* Delete DML - delete specific rows using where clause 
  
  
  Below is the MySQL code : 


```  
create database sql_work;
use sql_work;

#creating table 
create table Student(ID int unique, Name varchar(30) ,Position varchar(30)  ) ; 

#inserting data 
insert into Student( ID, Name, Position ) values (122232, 'Avik Goswami', 'tester'), (122233, 'Abhi Das', 'Data Architect') ,(122234, 'Manik Gupta', 'Developer'), (122235, 'Harshit Puri Goswami', 'tester') ;

#inserting data in the specific postion only
insert into Student(ID, Name) values (122236, 'Raman');

#delete command 
delete from Student where ID=122236;

#drop command 
Drop table Student;

#drop column command is different from drop command 
Alter Table Student Drop column Position; #it will delete the position column

#truncate command 
truncate Student ;

#viewing data 
select * from Student;
 
 ``` 