SlideShare a Scribd company logo
2
Most read
8/10/13 SQL DELETE, TRUNCATE, DROP Statements
beginner-sql-tutorial.com/sql-delete-statement.htm 1/2
SQL Delete Statement
The DELETE Statement is used to delete rows from a table.
The Syntax of a SQL DELETE statement is:
DELETE FROM table_name [WHERE condition];
table_name -- the table name which has to be updated.
NOTE:The WHERE clause in the sql delete command is optional and it identifies the rows in the column that gets
deleted. If you do not include the WHERE clause all the rows in the table is deleted, so be careful while writing a
DELETE query without WHERE clause.
For Example: To delete an employee with id 100 from the employee table, the sql delete query would be like,
DELETE FROM employee WHERE id = 100;
To delete all the rows from the employee table, the query would be like,
DELETE FROM employee;
SQL TRUNCATE Statement
The SQL TRUNCATE command is used to delete all the rows from the table and free the space containing the
table.
Syntax to TRUNCATE a table:
TRUNCATE TABLE table_name;
For Example: To delete all the rows from employee table, the query would be like,
TRUNCATE TABLE employee;
Difference between DELETE and TRUNCATE Statements:
DELETE Statement: This command deletes only the rows from the table based on the condition given in the
where clause or deletes all the rows from the table if no condition is specified. But it does not free the space
containing the table.
TRUNCATE statement: This command is used to delete all the rows from the table and free the space
containing the table.
SQL DROP Statement:
The SQL DROP command is used to remove an object from the database. If you drop a table, all the rows in the
table is deleted and the table structure is removed from the database. Once a table is dropped we cannot get it
back, so be careful while using DROP command. When a table is dropped all the references to the table will not
8/10/13 SQL DELETE, TRUNCATE, DROP Statements
beginner-sql-tutorial.com/sql-delete-statement.htm 2/2
be valid.
Syntax to drop a sql table structure:
DROP TABLE table_name;
For Example: To drop the table employee, the query would be like
DROP TABLE employee;
Difference between DROP and TRUNCATE Statement:
If a table is dropped, all the relationships with other tables will no longer be valid, the integrity constraints will be
dropped, grant or access privileges on the table will also be dropped, if want use the table again it has to be
recreated with the integrity constraints, access privileges and the relationships with other tables should be
established again. But, if a table is truncated, the table structure remains the same, therefore any of the above
problems will not exist.

More Related Content

PPTX
Joins And Its Types
Wings Interactive
 
PPTX
Sql(structured query language)
Ishucs
 
PPT
SQL Queries
Nilt1234
 
PPTX
SQL Commands
Sachidananda M H
 
PPTX
Group By, Having Clause and Order By clause
Deepam Aggarwal
 
ODP
Sql commands
Balakumaran Arunachalam
 
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
PPTX
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
Joins And Its Types
Wings Interactive
 
Sql(structured query language)
Ishucs
 
SQL Queries
Nilt1234
 
SQL Commands
Sachidananda M H
 
Group By, Having Clause and Order By clause
Deepam Aggarwal
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Presentation slides of Sequence Query Language (SQL)
Punjab University
 

What's hot (20)

PPT
Constraints In Sql
Anurag
 
PPT
Dbms relational model
Chirag vasava
 
PPT
Advanced sql
Dhani Ahmad
 
PPTX
SQL - DML and DDL Commands
Shrija Madhu
 
DOCX
Index in sql server
Durgaprasad Yadav
 
PPT
Introduction to sql
VARSHAKUMARI49
 
PPTX
Sql Constraints
I L0V3 CODING DR
 
PPT
Joins in SQL
Vigneshwaran Sankaran
 
PPTX
SQL Functions
ammarbrohi
 
PPTX
SQL commands
GirdharRatne
 
PPTX
Sql operator
Pooja Dixit
 
PPTX
introdution to SQL and SQL functions
farwa waqar
 
PPTX
Sql joins inner join self join outer joins
Deepthi Rachumallu
 
PPTX
Where conditions and Operators in SQL
MSB Academy
 
DOCX
Complex queries in sql
Charan Reddy
 
PPT
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru
 
PPTX
basic structure of SQL FINAL.pptx
Anusha sivakumar
 
PPT
Aggregate functions
sinhacp
 
PPTX
DDL And DML
pnp @in
 
PPTX
Oraclesql
Priya Goyal
 
Constraints In Sql
Anurag
 
Dbms relational model
Chirag vasava
 
Advanced sql
Dhani Ahmad
 
SQL - DML and DDL Commands
Shrija Madhu
 
Index in sql server
Durgaprasad Yadav
 
Introduction to sql
VARSHAKUMARI49
 
Sql Constraints
I L0V3 CODING DR
 
Joins in SQL
Vigneshwaran Sankaran
 
SQL Functions
ammarbrohi
 
SQL commands
GirdharRatne
 
Sql operator
Pooja Dixit
 
introdution to SQL and SQL functions
farwa waqar
 
Sql joins inner join self join outer joins
Deepthi Rachumallu
 
Where conditions and Operators in SQL
MSB Academy
 
Complex queries in sql
Charan Reddy
 
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru
 
basic structure of SQL FINAL.pptx
Anusha sivakumar
 
Aggregate functions
sinhacp
 
DDL And DML
pnp @in
 
Oraclesql
Priya Goyal
 
Ad

Viewers also liked (20)

PDF
Sql create table statement
Vivek Singh
 
PDF
Sql wksht-7
Mukesh Tekwani
 
PDF
Part 15 triggerr
Denny Yahya
 
PDF
Sql update statement
Vivek Singh
 
PPT
SQL Tutorial - How To Create, Drop, and Truncate Table
1keydata
 
PPT
Oracle Database Trigger
Eryk Budi Pratama
 
PPT
Chapter03
rwmiller
 
PDF
Ch4 notes for students
luismanuelmorais
 
PDF
3. frequency distribution
Ilham Bashir
 
PPTX
Data Representations
bujols
 
PPTX
Stem & leaf plots + histograms
ListeningDaisy
 
PPTX
6. triggers
Amrit Kaur
 
PDF
Sql insert statement
Vivek Singh
 
PDF
[Www.pkbulk.blogspot.com]dbms11
AnusAhmad
 
PPTX
Sql server ___________session_19(triggers)
Ehtisham Ali
 
PPTX
Finding Interquartile Range from Stem-Leaf Plot 1
Moonie Kim
 
PPTX
Symmetry and Skew
Passy World
 
PPTX
Stem and leaf plot
bbeiers
 
PPTX
SAP HANA - Manually to insert_data_table
Yasmin Ashraf
 
PPTX
Finding Interquartile Range from Stem-Leaf Plot 2
Moonie Kim
 
Sql create table statement
Vivek Singh
 
Sql wksht-7
Mukesh Tekwani
 
Part 15 triggerr
Denny Yahya
 
Sql update statement
Vivek Singh
 
SQL Tutorial - How To Create, Drop, and Truncate Table
1keydata
 
Oracle Database Trigger
Eryk Budi Pratama
 
Chapter03
rwmiller
 
Ch4 notes for students
luismanuelmorais
 
3. frequency distribution
Ilham Bashir
 
Data Representations
bujols
 
Stem & leaf plots + histograms
ListeningDaisy
 
6. triggers
Amrit Kaur
 
Sql insert statement
Vivek Singh
 
[Www.pkbulk.blogspot.com]dbms11
AnusAhmad
 
Sql server ___________session_19(triggers)
Ehtisham Ali
 
Finding Interquartile Range from Stem-Leaf Plot 1
Moonie Kim
 
Symmetry and Skew
Passy World
 
Stem and leaf plot
bbeiers
 
SAP HANA - Manually to insert_data_table
Yasmin Ashraf
 
Finding Interquartile Range from Stem-Leaf Plot 2
Moonie Kim
 
Ad

Similar to Sql delete, truncate, drop statements (20)

PDF
Sql alter table statement
Vivek Singh
 
PDF
Data Definition Language (DDL)
Mohd Tousif
 
DOCX
ii bcom dbms SQL Commands.docx
lakshmi77
 
PPTX
DDL Commands in Database Management System.pptx
chintanraval26
 
PPTX
Database Languages power point presentation
AshokRachapalli1
 
PPTX
GFGC CHIKKABASUR ( DDL COMMANDS )
GOVT FIRST GRADE COLLEGE CHIKKABASUR
 
DOC
Oracle sql material
prathap kumar
 
PDF
Interview Questions.pdf
TarunKumar893717
 
PPT
Les02
Sudharsan S
 
DOCX
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
PPTX
MySQL Essential Training
HudaRaghibKadhim
 
PDF
Assignment 3
SneaK3
 
PPT
Sql dml & tcl 2
Dr. C.V. Suresh Babu
 
PPTX
Introduction to database and sql fir beginers
reshmi30
 
PPT
Oracle naveen Sql
naveen
 
PPT
Oracle naveen Sql
naveen
 
PPTX
SQL Tutorial for Beginners
Abdelhay Shafi
 
PPTX
Sql tables
arwa wshyar
 
PDF
Sql smart reference_by_prasad
paddu123
 
Sql alter table statement
Vivek Singh
 
Data Definition Language (DDL)
Mohd Tousif
 
ii bcom dbms SQL Commands.docx
lakshmi77
 
DDL Commands in Database Management System.pptx
chintanraval26
 
Database Languages power point presentation
AshokRachapalli1
 
GFGC CHIKKABASUR ( DDL COMMANDS )
GOVT FIRST GRADE COLLEGE CHIKKABASUR
 
Oracle sql material
prathap kumar
 
Interview Questions.pdf
TarunKumar893717
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
MySQL Essential Training
HudaRaghibKadhim
 
Assignment 3
SneaK3
 
Sql dml & tcl 2
Dr. C.V. Suresh Babu
 
Introduction to database and sql fir beginers
reshmi30
 
Oracle naveen Sql
naveen
 
Oracle naveen Sql
naveen
 
SQL Tutorial for Beginners
Abdelhay Shafi
 
Sql tables
arwa wshyar
 
Sql smart reference_by_prasad
paddu123
 

More from Vivek Singh (20)

PPS
C programming session 14
Vivek Singh
 
PPS
C programming session 13
Vivek Singh
 
PPS
C programming session 11
Vivek Singh
 
PPS
C programming session 10
Vivek Singh
 
PPS
C programming session 08
Vivek Singh
 
PPS
C programming session 07
Vivek Singh
 
PPS
C programming session 05
Vivek Singh
 
PPS
C programming session 04
Vivek Singh
 
PPS
C programming session 02
Vivek Singh
 
PPS
C programming session 01
Vivek Singh
 
PPS
C programming session 16
Vivek Singh
 
PDF
Niit aptitude question paper
Vivek Singh
 
PDF
Excel shortcut and tips
Vivek Singh
 
PDF
Sql where clause
Vivek Singh
 
PDF
Sql tutorial, tutorials sql
Vivek Singh
 
PDF
Sql subquery
Vivek Singh
 
PDF
Sql select statement
Vivek Singh
 
PDF
Sql rename
Vivek Singh
 
PDF
Sql query tuning or query optimization
Vivek Singh
 
PDF
Sql query tips or query optimization
Vivek Singh
 
C programming session 14
Vivek Singh
 
C programming session 13
Vivek Singh
 
C programming session 11
Vivek Singh
 
C programming session 10
Vivek Singh
 
C programming session 08
Vivek Singh
 
C programming session 07
Vivek Singh
 
C programming session 05
Vivek Singh
 
C programming session 04
Vivek Singh
 
C programming session 02
Vivek Singh
 
C programming session 01
Vivek Singh
 
C programming session 16
Vivek Singh
 
Niit aptitude question paper
Vivek Singh
 
Excel shortcut and tips
Vivek Singh
 
Sql where clause
Vivek Singh
 
Sql tutorial, tutorials sql
Vivek Singh
 
Sql subquery
Vivek Singh
 
Sql select statement
Vivek Singh
 
Sql rename
Vivek Singh
 
Sql query tuning or query optimization
Vivek Singh
 
Sql query tips or query optimization
Vivek Singh
 

Recently uploaded (20)

PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
PDF
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
PDF
High Ground Student Revision Booklet Preview
jpinnuck
 
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
TumwineRobert
 
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PDF
5.Universal-Franchise-and-Indias-Electoral-System.pdfppt/pdf/8th class social...
Sandeep Swamy
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PDF
Introducing Procurement and Supply L2M1.pdf
labyankof
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
mansk2
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
High Ground Student Revision Booklet Preview
jpinnuck
 
Cardiovascular Pharmacology for pharmacy students.pptx
TumwineRobert
 
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
5.Universal-Franchise-and-Indias-Electoral-System.pdfppt/pdf/8th class social...
Sandeep Swamy
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Introducing Procurement and Supply L2M1.pdf
labyankof
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
Week 4 Term 3 Study Techniques revisited.pptx
mansk2
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 

Sql delete, truncate, drop statements

  • 1. 8/10/13 SQL DELETE, TRUNCATE, DROP Statements beginner-sql-tutorial.com/sql-delete-statement.htm 1/2 SQL Delete Statement The DELETE Statement is used to delete rows from a table. The Syntax of a SQL DELETE statement is: DELETE FROM table_name [WHERE condition]; table_name -- the table name which has to be updated. NOTE:The WHERE clause in the sql delete command is optional and it identifies the rows in the column that gets deleted. If you do not include the WHERE clause all the rows in the table is deleted, so be careful while writing a DELETE query without WHERE clause. For Example: To delete an employee with id 100 from the employee table, the sql delete query would be like, DELETE FROM employee WHERE id = 100; To delete all the rows from the employee table, the query would be like, DELETE FROM employee; SQL TRUNCATE Statement The SQL TRUNCATE command is used to delete all the rows from the table and free the space containing the table. Syntax to TRUNCATE a table: TRUNCATE TABLE table_name; For Example: To delete all the rows from employee table, the query would be like, TRUNCATE TABLE employee; Difference between DELETE and TRUNCATE Statements: DELETE Statement: This command deletes only the rows from the table based on the condition given in the where clause or deletes all the rows from the table if no condition is specified. But it does not free the space containing the table. TRUNCATE statement: This command is used to delete all the rows from the table and free the space containing the table. SQL DROP Statement: The SQL DROP command is used to remove an object from the database. If you drop a table, all the rows in the table is deleted and the table structure is removed from the database. Once a table is dropped we cannot get it back, so be careful while using DROP command. When a table is dropped all the references to the table will not
  • 2. 8/10/13 SQL DELETE, TRUNCATE, DROP Statements beginner-sql-tutorial.com/sql-delete-statement.htm 2/2 be valid. Syntax to drop a sql table structure: DROP TABLE table_name; For Example: To drop the table employee, the query would be like DROP TABLE employee; Difference between DROP and TRUNCATE Statement: If a table is dropped, all the relationships with other tables will no longer be valid, the integrity constraints will be dropped, grant or access privileges on the table will also be dropped, if want use the table again it has to be recreated with the integrity constraints, access privileges and the relationships with other tables should be established again. But, if a table is truncated, the table structure remains the same, therefore any of the above problems will not exist.