SQL DELETE Statement: Syntax and Examples
The 'DELETE' syntax is used to delete existing records from a database table. The general syntax is as follows:
DELETE FROM table_name
WHERE condition;
- 'DELETE FROM': Specifies that you want to delete records from a table.
- 'table_name': Specifies the name of the table from which you want to delete records.
- 'WHERE condition': Specifies the condition that determines which records should be deleted. This is optional, and if not specified, all records in the table will be deleted.
Example:
Suppose we have a table named 'customers' with columns 'id', 'name', and 'age'. To delete a specific record from the table, you can use the following command:
DELETE FROM customers
WHERE id = 1;
This will delete the record with 'id' value 1 from the 'customers' table.
If you want to delete all records from the table, you can omit the 'WHERE' clause:
DELETE FROM customers;
This will delete all records from the 'customers' table.
原文地址: https://www.cveoy.top/t/topic/pjdV 著作权归作者所有。请勿转载和采集!