SQL Tutorial
SQL Database
SQL Table
SQL Select
SQL Order By
SQL Insert
SQL Update
SQL Delete
Difference
SQL Injection
SQL String Functions
Miscl
- SQL Formatter
- SQL group by
- SQL add/drop/update column operation
- SQL CAST Function
- SQL Comments
- SQL CONCAT Function
- CTE (Common Table Expression)SQL
- How to use distinct in SQL?
- Joining Three or More Tables in SQL
- What is Web SQL?
- How to create functions in SQL?
- How to run SQL Script?
- How to Delete Duplicate Rows in SQL?
- Nth Highest salary
- 12 Codd's Rules
- SQL EXCEPT
- Types of SQL JOIN
- Change datatype of column in SQL
- SQL Auto Increment
- SQL Like
- Commit and Rollback in SQL
- SQL Concatenate
- SQL get month from the date
- Savepoint in SQL
- SQL ORDER BY DATE
- TIME Datatype in SQL
- SQL BETWEEN
- CRUD Operations in SQL
- SQL INDEX
- Scalar Functions in SQL
- SET Operators in SQL
- Types of SQL Commands
- TCL Commands in SQL
- SQL Subquery
- SQL View
- Constraints in SQL
- Pattern Matching in SQL
- SQL Date Functions
- DDL Commands in SQL
- DML Commands in SQL
- SQL CASE
- SQL Inner Join
- SQL IN Operator
- Check Constraint in SQL
- SQL CLAUSES
- SQL LOGICAL OPERATORS
- Delete Column from Table
- Add Column in the Table
- Delete one row in SQL
- Change the Column Value
- How to Add Foreign Key in SQL
- Add a Primary Key
- Insert One or More rows
- How to Use LIKE in SQL
- Cursor in SQL
- Difference Between DROP and Truncate
- SQL Comparison Operators
- SQL COUNT WHERE
- SQL SELECT MIN
- SQL Stored Procedure
- SQL SELECT AVG
- SQL SELECT MAX
- SQL ADD COLUMN
- How to use Auto-Increment in SQL
- SQL Languages
- SQL Arithmetic Operators
- How to Use GROUP BY in SQL
- How to Use ORDER BY in SQL
- Trigger in SQL
- What is Race Condition
- SQL COUNT DISTINCT
PL/SQL Tutorial
Sql Interview Question
SQl Quiz
SQL DELETE
The SQL DELETE statement is used to delete rows from a table. Generally DELETE statement removes one or more records from a table.
SQL DELETE Syntax
Let's see the Syntax for the SQL DELETE statement:
Here table_name is the table which has to be deleted. The WHERE clause in SQL DELETE statement is optional here.
SQL DELETE Example
Let us take a table, named "EMPLOYEE" table.
ID | EMP_NAME | CITY | SALARY |
---|---|---|---|
101 | Adarsh Singh | Obra | 20000 |
102 | Sanjay Singh | Meerut | 21000 |
103 | Priyanka Sharma | Raipur | 25000 |
104 | Esha Singhal | Delhi | 26000 |
Example of delete with WHERE clause is given below:
Resulting table after the query:
ID | EMP_NAME | CITY | SALARY |
---|---|---|---|
102 | Sanjay Singh | Meerut | 21000 |
103 | Priyanka Sharma | Raipur | 25000 |
104 | Esha Singhal | Delhi | 26000 |
Another example of delete statement is given below
Resulting table after the query:
ID | EMP_NAME | CITY | SALARY |
---|
It will delete all the records of EMPLOYEE table.
It will delete the all the records of EMPLOYEE table where ID is 101.
The WHERE clause in the SQL DELETE statement is optional and it identifies the rows in the column that gets deleted.
WHERE clause is used to prevent the deletion of all the rows in the table, If you don't use the WHERE clause you might loss all the rows.
Invalid DELETE Statement for ORACLE database
You cannot use * (asterisk) symbol to delete all the records.
Topics of SQL DELETE Statement
SQL DELETE TABLE
How to delete the table and what is the difference between DELETE and TRUNCATE statement?
SQL DELETE ROW
How to delete a row from the database?
SQL DELETE All Rows
How to delete all the rows of a table?
SQL DELETE Duplicate Rows
How to use distinct keyword to delete all the duplicate rows from the table?
SQL DELETE DATABASE
There is not used DELETE statement to delete the database. But, there is used DROP statement to delete the database.
SQL DELETE VIEW
How to delete the view from the database?
SQL DELETE JOIN
How to use delete statement with INNER JOIN?