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
SQL - DML and DDL Commands
PPT
Sql DML
PPTX
Group By, Having Clause and Order By clause
PPT
PPTX
SQL Commands
PPT
Including Constraints -Oracle Data base
PDF
SQL Queries - DDL Commands
PPTX
introdution to SQL and SQL functions
SQL - DML and DDL Commands
Sql DML
Group By, Having Clause and Order By clause
SQL Commands
Including Constraints -Oracle Data base
SQL Queries - DDL Commands
introdution to SQL and SQL functions

What's hot (20)

PPTX
Presentation slides of Sequence Query Language (SQL)
PPTX
Sql Constraints
PPTX
What is SQL Server?
PPT
Constraints In Sql
PPTX
SQL commands
PPT
SQL subquery
PPTX
Sql joins inner join self join outer joins
PPT
PPTX
Ddl & dml commands
PPTX
Excel presentation data validation
PPTX
DATABASE CONSTRAINTS
PPT
1 - Introduction to PL/SQL
PPTX
sql function(ppt)
PPTX
set operators.pptx
PPTX
SQL(DDL & DML)
PPT
Chapter8 pl sql
PPT
Sql basics and DDL statements
PDF
SQL Overview
PPTX
Aggregate function
Presentation slides of Sequence Query Language (SQL)
Sql Constraints
What is SQL Server?
Constraints In Sql
SQL commands
SQL subquery
Sql joins inner join self join outer joins
Ddl & dml commands
Excel presentation data validation
DATABASE CONSTRAINTS
1 - Introduction to PL/SQL
sql function(ppt)
set operators.pptx
SQL(DDL & DML)
Chapter8 pl sql
Sql basics and DDL statements
SQL Overview
Aggregate function
Ad

Viewers also liked (20)

PDF
Sql create table statement
PDF
Sql wksht-7
ODP
PDF
Part 15 triggerr
PDF
Sql update statement
PPT
SQL Tutorial - How To Create, Drop, and Truncate Table
PPT
Oracle Database Trigger
PPT
Chapter03
PDF
Ch4 notes for students
PDF
3. frequency distribution
PPTX
Data Representations
PPTX
Stem & leaf plots + histograms
PPTX
6. triggers
PDF
Sql insert statement
PDF
[Www.pkbulk.blogspot.com]dbms11
PPTX
Sql server ___________session_19(triggers)
PPTX
Finding Interquartile Range from Stem-Leaf Plot 1
PPTX
Symmetry and Skew
PPTX
Stem and leaf plot
PPTX
SAP HANA - Manually to insert_data_table
Sql create table statement
Sql wksht-7
Part 15 triggerr
Sql update statement
SQL Tutorial - How To Create, Drop, and Truncate Table
Oracle Database Trigger
Chapter03
Ch4 notes for students
3. frequency distribution
Data Representations
Stem & leaf plots + histograms
6. triggers
Sql insert statement
[Www.pkbulk.blogspot.com]dbms11
Sql server ___________session_19(triggers)
Finding Interquartile Range from Stem-Leaf Plot 1
Symmetry and Skew
Stem and leaf plot
SAP HANA - Manually to insert_data_table
Ad

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

PDF
Sql alter table statement
PDF
Data Definition Language (DDL)
DOCX
ii bcom dbms SQL Commands.docx
PPTX
DDL Commands in Database Management System.pptx
PPTX
Database Languages power point presentation
PPTX
GFGC CHIKKABASUR ( DDL COMMANDS )
DOC
Oracle sql material
PPT
DOCX
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
PPTX
MySQL Essential Training
PDF
Assignment 3
PPT
Sql dml & tcl 2
PPTX
Introduction to database and sql fir beginers
PPTX
Oraclesql
PPT
Oracle naveen Sql
PPT
Oracle naveen Sql
PPTX
SQL Tutorial for Beginners
PPTX
Sql tables
PDF
Sql smart reference_by_prasad
Sql alter table statement
Data Definition Language (DDL)
ii bcom dbms SQL Commands.docx
DDL Commands in Database Management System.pptx
Database Languages power point presentation
GFGC CHIKKABASUR ( DDL COMMANDS )
Oracle sql material
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
MySQL Essential Training
Assignment 3
Sql dml & tcl 2
Introduction to database and sql fir beginers
Oraclesql
Oracle naveen Sql
Oracle naveen Sql
SQL Tutorial for Beginners
Sql tables
Sql smart reference_by_prasad

More from Vivek Singh (20)

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

Recently uploaded (20)

PDF
RMMM.pdf make it easy to upload and study
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Complications of Minimal Access Surgery at WLH
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Structure & Organelles in detailed.
PPTX
Cell Types and Its function , kingdom of life
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Computing-Curriculum for Schools in Ghana
PDF
01-Introduction-to-Information-Management.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
RMMM.pdf make it easy to upload and study
Microbial disease of the cardiovascular and lymphatic systems
Complications of Minimal Access Surgery at WLH
STATICS OF THE RIGID BODIES Hibbelers.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Classroom Observation Tools for Teachers
Cell Structure & Organelles in detailed.
Cell Types and Its function , kingdom of life
Anesthesia in Laparoscopic Surgery in India
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
O5-L3 Freight Transport Ops (International) V1.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Final Presentation General Medicine 03-08-2024.pptx
VCE English Exam - Section C Student Revision Booklet
Computing-Curriculum for Schools in Ghana
01-Introduction-to-Information-Management.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

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.