SlideShare a Scribd company logo
1 of 2
Download to read offline
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)

introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
SQL Constraints
SQL ConstraintsSQL Constraints
SQL Constraints
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTSDATABASE CONSTRAINTS
DATABASE CONSTRAINTS
 
SQL
SQLSQL
SQL
 
Sql select
Sql select Sql select
Sql select
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Oracle basic queries
Oracle basic queriesOracle basic queries
Oracle basic queries
 
SQL
SQLSQL
SQL
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
Create table
Create tableCreate table
Create table
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Database queries
Database queriesDatabase queries
Database queries
 

Viewers also liked

Sql create table statement
Sql create table statementSql create table statement
Sql create table statementVivek Singh
 
Part 15 triggerr
Part 15  triggerrPart 15  triggerr
Part 15 triggerrDenny Yahya
 
Sql update statement
Sql update statementSql update statement
Sql update statementVivek Singh
 
SQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate TableSQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate Table1keydata
 
3. frequency distribution
3. frequency distribution3. frequency distribution
3. frequency distributionIlham Bashir
 
Data Representations
Data RepresentationsData Representations
Data Representationsbujols
 
Stem & leaf plots + histograms
Stem & leaf plots + histogramsStem & leaf plots + histograms
Stem & leaf plots + histogramsListeningDaisy
 
Sql insert statement
Sql insert statementSql insert statement
Sql insert statementVivek Singh
 
[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11AnusAhmad
 
Sql server ___________session_19(triggers)
Sql server  ___________session_19(triggers)Sql server  ___________session_19(triggers)
Sql server ___________session_19(triggers)Ehtisham Ali
 
Finding Interquartile Range from Stem-Leaf Plot 1
Finding Interquartile Range from Stem-Leaf Plot 1Finding Interquartile Range from Stem-Leaf Plot 1
Finding Interquartile Range from Stem-Leaf Plot 1Moonie Kim
 
Symmetry and Skew
Symmetry and Skew Symmetry and Skew
Symmetry and Skew Passy World
 
Stem and leaf plot
Stem and leaf plotStem and leaf plot
Stem and leaf plotbbeiers
 
SAP HANA - Manually to insert_data_table
SAP HANA - Manually to insert_data_tableSAP HANA - Manually to insert_data_table
SAP HANA - Manually to insert_data_tableYasmin Ashraf
 
Finding Interquartile Range from Stem-Leaf Plot 2
Finding Interquartile Range from Stem-Leaf Plot 2Finding Interquartile Range from Stem-Leaf Plot 2
Finding Interquartile Range from Stem-Leaf Plot 2Moonie Kim
 

Viewers also liked (20)

Sql create table statement
Sql create table statementSql create table statement
Sql create table statement
 
Sql wksht-7
Sql wksht-7Sql wksht-7
Sql wksht-7
 
Part 15 triggerr
Part 15  triggerrPart 15  triggerr
Part 15 triggerr
 
Sql update statement
Sql update statementSql update statement
Sql update statement
 
SQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate TableSQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate Table
 
Oracle Database Trigger
Oracle Database TriggerOracle Database Trigger
Oracle Database Trigger
 
Chapter03
Chapter03Chapter03
Chapter03
 
Ch4 notes for students
Ch4 notes for studentsCh4 notes for students
Ch4 notes for students
 
3. frequency distribution
3. frequency distribution3. frequency distribution
3. frequency distribution
 
Data Representations
Data RepresentationsData Representations
Data Representations
 
Stem & leaf plots + histograms
Stem & leaf plots + histogramsStem & leaf plots + histograms
Stem & leaf plots + histograms
 
6. triggers
6. triggers6. triggers
6. triggers
 
Sql insert statement
Sql insert statementSql insert statement
Sql insert statement
 
[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11
 
Sql server ___________session_19(triggers)
Sql server  ___________session_19(triggers)Sql server  ___________session_19(triggers)
Sql server ___________session_19(triggers)
 
Finding Interquartile Range from Stem-Leaf Plot 1
Finding Interquartile Range from Stem-Leaf Plot 1Finding Interquartile Range from Stem-Leaf Plot 1
Finding Interquartile Range from Stem-Leaf Plot 1
 
Symmetry and Skew
Symmetry and Skew Symmetry and Skew
Symmetry and Skew
 
Stem and leaf plot
Stem and leaf plotStem and leaf plot
Stem and leaf plot
 
SAP HANA - Manually to insert_data_table
SAP HANA - Manually to insert_data_tableSAP HANA - Manually to insert_data_table
SAP HANA - Manually to insert_data_table
 
Finding Interquartile Range from Stem-Leaf Plot 2
Finding Interquartile Range from Stem-Leaf Plot 2Finding Interquartile Range from Stem-Leaf Plot 2
Finding Interquartile Range from Stem-Leaf Plot 2
 

Similar to Sql delete, truncate, drop statements

Sql alter table statement
Sql alter table statementSql alter table statement
Sql alter table statementVivek Singh
 
Data Definition Language (DDL)
Data Definition Language (DDL) Data Definition Language (DDL)
Data Definition Language (DDL) Mohd Tousif
 
ii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docxii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docxlakshmi77
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...SakkaravarthiS1
 
Assignment 3
Assignment 3Assignment 3
Assignment 3SneaK3
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sqlnaveen
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sqlnaveen
 
SQL Tutorial for Beginners
SQL Tutorial for BeginnersSQL Tutorial for Beginners
SQL Tutorial for BeginnersAbdelhay Shafi
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 

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

Sql alter table statement
Sql alter table statementSql alter table statement
Sql alter table statement
 
Data Definition Language (DDL)
Data Definition Language (DDL) Data Definition Language (DDL)
Data Definition Language (DDL)
 
ii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docxii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docx
 
GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 
Sql
SqlSql
Sql
 
Interview Questions.pdf
Interview Questions.pdfInterview Questions.pdf
Interview Questions.pdf
 
Les02
Les02Les02
Les02
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
 
Assignment 3
Assignment 3Assignment 3
Assignment 3
 
Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
 
SQL Tutorial for Beginners
SQL Tutorial for BeginnersSQL Tutorial for Beginners
SQL Tutorial for Beginners
 
Sql tables
Sql tablesSql tables
Sql tables
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Babitha2.mysql
Babitha2.mysqlBabitha2.mysql
Babitha2.mysql
 
Babitha2 Mysql
Babitha2 MysqlBabitha2 Mysql
Babitha2 Mysql
 

More from Vivek Singh

C programming session 14
C programming session 14C programming session 14
C programming session 14Vivek Singh
 
C programming session 13
C programming session 13C programming session 13
C programming session 13Vivek Singh
 
C programming session 11
C programming session 11C programming session 11
C programming session 11Vivek Singh
 
C programming session 10
C programming session 10C programming session 10
C programming session 10Vivek Singh
 
C programming session 08
C programming session 08C programming session 08
C programming session 08Vivek Singh
 
C programming session 07
C programming session 07C programming session 07
C programming session 07Vivek Singh
 
C programming session 05
C programming session 05C programming session 05
C programming session 05Vivek Singh
 
C programming session 04
C programming session 04C programming session 04
C programming session 04Vivek Singh
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Vivek Singh
 
C programming session 01
C programming session 01C programming session 01
C programming session 01Vivek Singh
 
C programming session 16
C programming session 16C programming session 16
C programming session 16Vivek Singh
 
Niit aptitude question paper
Niit aptitude question paperNiit aptitude question paper
Niit aptitude question paperVivek Singh
 
Excel shortcut and tips
Excel shortcut and tipsExcel shortcut and tips
Excel shortcut and tipsVivek Singh
 
Sql where clause
Sql where clauseSql where clause
Sql where clauseVivek Singh
 
Sql tutorial, tutorials sql
Sql tutorial, tutorials sqlSql tutorial, tutorials sql
Sql tutorial, tutorials sqlVivek Singh
 
Sql select statement
Sql select statementSql select statement
Sql select statementVivek Singh
 
Sql query tuning or query optimization
Sql query tuning or query optimizationSql query tuning or query optimization
Sql query tuning or query optimizationVivek Singh
 
Sql query tips or query optimization
Sql query tips or query optimizationSql query tips or query optimization
Sql query tips or query optimizationVivek Singh
 

More from Vivek Singh (20)

C programming session 14
C programming session 14C programming session 14
C programming session 14
 
C programming session 13
C programming session 13C programming session 13
C programming session 13
 
C programming session 11
C programming session 11C programming session 11
C programming session 11
 
C programming session 10
C programming session 10C programming session 10
C programming session 10
 
C programming session 08
C programming session 08C programming session 08
C programming session 08
 
C programming session 07
C programming session 07C programming session 07
C programming session 07
 
C programming session 05
C programming session 05C programming session 05
C programming session 05
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
C programming session 16
C programming session 16C programming session 16
C programming session 16
 
Niit aptitude question paper
Niit aptitude question paperNiit aptitude question paper
Niit aptitude question paper
 
Excel shortcut and tips
Excel shortcut and tipsExcel shortcut and tips
Excel shortcut and tips
 
Sql where clause
Sql where clauseSql where clause
Sql where clause
 
Sql tutorial, tutorials sql
Sql tutorial, tutorials sqlSql tutorial, tutorials sql
Sql tutorial, tutorials sql
 
Sql subquery
Sql subquerySql subquery
Sql subquery
 
Sql select statement
Sql select statementSql select statement
Sql select statement
 
Sql rename
Sql renameSql rename
Sql rename
 
Sql query tuning or query optimization
Sql query tuning or query optimizationSql query tuning or query optimization
Sql query tuning or query optimization
 
Sql query tips or query optimization
Sql query tips or query optimizationSql query tips or query optimization
Sql query tips or query optimization
 

Recently uploaded

Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Recently uploaded (20)

Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

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.