SQL Delete Statement


SQL Delete Statement

To delete a record in a table you use the DELETE statement.

Be careful. You can delete all records of the table or just a few. Use the WHERE condition to specify which records do you want to delete. The syntax is:

DELETE FROM table_name WHERE condition;

Here is an example deleting from the table Person the record with Id 3:

DELETE FROM Person WHERE Id = 3;

Using DELETE to remove all records from a given table

DELETE * FROM Person ;

Or depending on your RDBMS you could use the TRUNCATE TABLE statement which deletes all records from a table and depending on your RDBMS may or may not allow rollback. DELETE is DML and TRUNCATE is DDL.

TRUNCATE TABLE Person;

More Information

This article needs improvement. You can help improve this article. You can also write similar articles and help the community.