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

What's hot (20)

PPTX
Null values, insert, delete and update in database
Hemant Suthar
 
PPTX
AGGREGATE FUNCTION.pptx
Anusha sivakumar
 
PPTX
sql function(ppt)
Ankit Dubey
 
PPT
SQL subquery
Vikas Gupta
 
PPT
Sql operators & functions 3
Dr. C.V. Suresh Babu
 
PPTX
SQL(DDL & DML)
Sharad Dubey
 
PPT
SQL select clause
arpit bhadoriya
 
PPT
PL/SQL Introduction and Concepts
Bharat Kalia
 
PPTX
Sql - Structured Query Language
Wan Hussain Wan Ishak
 
PDF
SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
PPTX
Dbms keys
RUpaliLohar
 
PDF
PL-SQL, Cursors & Triggers
Shalabh Chaudhary
 
PPTX
8. sql
khoahuy82
 
PDF
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
Kathirvel Ayyaswamy
 
PPTX
SQL Basics
Hammad Rasheed
 
PDF
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
PPTX
Normalization 1 nf,2nf,3nf,bcnf
Shriya agrawal
 
PPTX
SQL - Structured query language introduction
Smriti Jain
 
Null values, insert, delete and update in database
Hemant Suthar
 
AGGREGATE FUNCTION.pptx
Anusha sivakumar
 
sql function(ppt)
Ankit Dubey
 
SQL subquery
Vikas Gupta
 
Sql operators & functions 3
Dr. C.V. Suresh Babu
 
SQL(DDL & DML)
Sharad Dubey
 
SQL select clause
arpit bhadoriya
 
PL/SQL Introduction and Concepts
Bharat Kalia
 
Sql - Structured Query Language
Wan Hussain Wan Ishak
 
SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
Dbms keys
RUpaliLohar
 
PL-SQL, Cursors & Triggers
Shalabh Chaudhary
 
8. sql
khoahuy82
 
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
Kathirvel Ayyaswamy
 
SQL Basics
Hammad Rasheed
 
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
Normalization 1 nf,2nf,3nf,bcnf
Shriya agrawal
 
SQL - Structured query language introduction
Smriti Jain
 

Viewers also liked (20)

PDF
Sql create table statement
Vivek Singh
 
PDF
Sql wksht-7
Mukesh Tekwani
 
ODP
Sql commands
Balakumaran Arunachalam
 
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
 
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
 
Ad

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

PPTX
DDL Commands in Database Management System.pptx
chintanraval26
 
PPTX
Oracle truncate&alter (1)
rishisingh190
 
PPTX
SQL.pptx for the begineers and good know
PavithSingh
 
PPTX
SQL Commands Part 3.pptx
RUBAB79
 
PPTX
1.2 sql create and drop table
MLG College of Learning, Inc
 
PDF
Data Definition Language (DDL)
Mohd Tousif
 
PPTX
Commands of DML in SQL
Ashish Gaurkhede
 
PDF
Interview Questions.pdf
TarunKumar893717
 
PPTX
introdution to SQL and SQL functions
farwa waqar
 
PPTX
Lecture - MY-SQL/ SQL Commands - DDL.pptx
umershah0263
 
PPTX
Oraclesql
Priya Goyal
 
DOC
Oracle sql material
prathap kumar
 
PPTX
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
NathRam2
 
DOCX
SQL Tutorial for BCA-2
Raj vardhan
 
PDF
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
PPTX
DML Statements.pptx
UnitedGamer1
 
PDF
Sql tutorial
amitabros
 
PPTX
SQL
Jerin John
 
PPTX
SQL
Jerin John
 
PPTX
SQl data base management and design
franckelsania20
 
DDL Commands in Database Management System.pptx
chintanraval26
 
Oracle truncate&alter (1)
rishisingh190
 
SQL.pptx for the begineers and good know
PavithSingh
 
SQL Commands Part 3.pptx
RUBAB79
 
1.2 sql create and drop table
MLG College of Learning, Inc
 
Data Definition Language (DDL)
Mohd Tousif
 
Commands of DML in SQL
Ashish Gaurkhede
 
Interview Questions.pdf
TarunKumar893717
 
introdution to SQL and SQL functions
farwa waqar
 
Lecture - MY-SQL/ SQL Commands - DDL.pptx
umershah0263
 
Oraclesql
Priya Goyal
 
Oracle sql material
prathap kumar
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
NathRam2
 
SQL Tutorial for BCA-2
Raj vardhan
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
DML Statements.pptx
UnitedGamer1
 
Sql tutorial
amitabros
 
SQl data base management and design
franckelsania20
 
Ad

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
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
Difference between write and update in odoo 18
Celine George
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Introduction presentation of the patentbutler tool
MIPLM
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
infertility, types,causes, impact, and management
Ritu480198
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
Council of Chalcedon Re-Examined
Smiling Lungs
 

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.