To eliminate rows from a table, using the SQL DELETE statement. Depending on certain criteria, it permits the deletion of one or more records. If the WHERE clause is not included, all records in the table will be removed.
Complete Python Course with Advance topics:-Click Here SQL Tutorial :-Click Here
SQL DELETE Syntax
The syntax for the SQL DELETE statement is as follows:
DELETE FROM table_name [WHERE condition];
table_name: The name of the table from which records are to be deleted.
WHERE condition: Specifies which rows should be deleted. If omitted, all rows will be deleted.
SQL DELETE Example
Consider a table named STUDENT:
ID
STUDENT_NAME
CITY
GRADE
201
Aryan Verma
Lucknow
A
202
Riya Sharma
Bhopal
B+
203
Karan Mehta
Jaipur
A-
204
Neha Gupta
Mumbai
B
Deleting a Specific Record
To delete a record where ID = 201:
DELETE FROM STUDENT WHERE ID=201;
Resulting Table:
ID
STUDENT_NAME
CITY
GRADE
202
Riya Sharma
Bhopal
B+
203
Karan Mehta
Jaipur
A-
204
Neha Gupta
Mumbai
B
Deleting All Records
To remove all records from the table:
DELETE FROM STUDENT;
Resulting Table:
ID
STUDENT_NAME
CITY
GRADE
Â
Â
Â
Â
This deletes all rows from the STUDENT table.
Importance of WHERE Clause in DELETE Statement
The WHERE clause is crucial in the DELETE statement as it prevents unintended deletion of all records. Omitting WHERE may result in the loss of all data in the table.
Latest Student Projects
Python Tkinter Text Widget: A Comprehensive Guide
Understanding SQL Injection: A Major Web Security Threat
WHERE Condition in SQL
Difference Between WHERE and HAVING in SQL
GROUP BY vs ORDER BY in SQL
IN vs EXISTS in SQL: A Complete Guide
SQL vs NoSQL: A Detailed Comparison
Understanding UNIQUE Key in SQL with Examples
SQL Composite Key: Understanding Multi-Column Uniqueness
Python Tkinter Checkbutton – A Complete Guide
SQL FOREIGN KEY: Understanding and Implementing in Relational Databases
Understanding SQL Primary Key: A Comprehensive Guide
Understanding SQL CROSS JOIN with Examples
SQL FULL JOIN – A Complete Guide
SQL RIGHT JOIN: A Comprehensive Guide
Understanding SQL LEFT JOIN with Examples
SQL OUTER JOIN: A Comprehensive Guide
Understanding SQL JOIN with Examples
SQL DELETE JOIN: A Comprehensive Guide
SQL DELETE VIEW
SQL DELETE DATABASE – A Complete Guide
SQL DELETE DUPLICATE ROWS
SQL DELETE ROW: How to Remove Records from a Table
Understanding SQL DELETE Statement with Example
SQL DELETE TABLE: Understanding DELETE, TRUNCATE, and DROP Statements
SQL UPDATE DATE: How to Update a Date and Time Field in SQL?
SQL UPDATE with JOIN
SQL UPDATE Statement: A Complete Guide
SQL INSERT Multiple Rows: A Time-Saving Technique
SQL INSERT STATEMENT
SQL ORDER BY LIMIT – Retrieve Specific Rows from a Database
SQL ORDER BY RANDOM: Fetching Random Records in Databases
SQL ORDER BY Clause with Descending Order
SQL ORDER BY Clause with Ascending Order
SQL ORDER BY Clause: Sorting Data in a Structured Manner
HAVING Clause in SQL
SQL SELECT AS – Column and Table Aliases in SQL
SQL WITH Clause
SQL DELETE Statement
SQL DELETE Statement
SQL DELETE Statement
To eliminate rows from a table, using the SQL DELETE statement. Depending on certain criteria, it permits the deletion of one or more records. If the
WHEREclause is not included, all records in the table will be removed.Complete Python Course with Advance topics:-Click Here
SQL Tutorial :-Click Here
SQL DELETE Syntax
The syntax for the SQL DELETE statement is as follows:
table_name: The name of the table from which records are to be deleted.WHERE condition: Specifies which rows should be deleted. If omitted, all rows will be deleted.SQL DELETE Example
Consider a table named STUDENT:
Deleting a Specific Record
To delete a record where
ID = 201:Resulting Table:
Deleting All Records
To remove all records from the table:
Resulting Table:
This deletes all rows from the STUDENT table.
Importance of WHERE Clause in DELETE Statement
The
WHEREclause is crucial in the DELETE statement as it prevents unintended deletion of all records. OmittingWHEREmay result in the loss of all data in the table.Invalid DELETE Statement in ORACLE
In Oracle, using
*in the DELETE statement is invalid:This will result in an error. Instead, use:
Download New Real Time Projects :-Click here
Complete Advance AI topics:-Â CLICK HERE
This guide provides a clear understanding of the SQL DELETE statement and its best practices. For more detailed SQL tutorials, visit UpdateGadh!
🎓 Need Complete Final Year Project?
Get Source Code + Report + PPT + Viva Questions (Instant Access)
🛒 Visit UpdateGadh Store →