Learn how to SQL DELETE statement and delete rows of a table. Find out how to delete specified data or all data of a table using SQL DELETE statement.
Sometimes, you need to delete rows of a table when not required for the table of your database. Deleting record of a table can be useful to maintain the accuracy of a table.
You can delete a single record or multiple records of a table using the syntax given below.
How to Use SQL DELETE Statement to Delete Rows of a Table
There are two syntaxes of SQL DELETE statement to delete data of a table. To delete only the specified record of a table, you need to use the WHERE conditional statement to delete the required record. If you do not specify the WHERE condition, the above statement deletes all the data of a table.
Syntax1: Delete Specified Data of a Table.
DELETE FROM tablename
The above syntax deletes only the specified data of a table in the WHERE condition. You have to specify only the table name and the condition by which the required record gets deleted using the DELETE statement.
Syntax2: Delete All Data of a Table.
DELETE FROM tablename;
The above syntax deletes all the data of a table. Be careful before using this syntax as you may lose all the data of a table which is not reversible.
|1||tablename||Specify the table name from which you want to delete the data of a table.|
|2||condition||Specify the condition by which only the specified record of a table gets deleted.|
Examples to Use SQL DELETE Statement
DELETE FROM Employee
DELETE FROM Employee;
You must also learn.