SQL Delete
How to Delete Data in SQL
You have already learned how to drop a table and a view, and now you’ll learn the SQL Delete statement. DROP and DELETE are two different operations to remove data from a database. The SQL DELETE removes specific rows of data from a table, while DROP removes an entire database object.
Here’s the syntax for the SQL DELETE:
DELETE
FROM
table_name
WHERE
condition;
For example, suppose you have a tv_show table, and you want to delete all the records launched after 2000. The SQL statement would be:
DELETE
FROM
tv_show
WHERE
year_launch > 2000
;
Note that it’s recommended to back up the database before executing a DELETE statement, as the SQL DELETE permanently removes data from a table.
An Easier Way to Delete Data
If you are in Coginti, you can right-click the table you want to delete data. The application will generate the code with the proper schema, and you can fulfill the conditions to specify what will be deleted.