DELETE (Version 2.0)
更新时间:
复制 MD 格式
Use DELETE to delete records from a table.
Syntax
DELETE FROM table_name
[ WHERE condition ]Examples
- Delete records from the customer table where the name is 'Zhang San':
DELETE FROM customer WHERE name='Zhang San'; - Delete all records from the customer table:
DELETE FROM customer WHERE 1=1;
Usage notes
- Deleting all data from a large table can cause critical performance issues. If a table contains more than 100,000 records, delete and recreate the table instead of using the DELETE statement.
- DELETE statements do not support table aliases.
- The WHERE clause in a DELETE statement does not support subqueries or functions.
- DELETE statements for tables with subpartitions must include a subpartition condition. For example, to delete data for February from the trade table where biz_date is the subpartition column:
DELETE FROM trade where biz_date>=20180201 and biz_date<=20180228; - Frequent DELETE operations can also cause performance issues. For optimal performance, include the primary key in the WHERE clause.
该文章对您有帮助吗?