freeCodeCamp/guide/chinese/sql/sql-delete-statement/index.md

35 lines
728 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: SQL Delete Statement
localeTitle: SQL删除语句
---
## SQL删除语句
要删除表中的记录,请使用`DELETE`语句。
小心。您可以删除表格的所有记录或只删除一些记录。使用`WHERE`条件指定要删除的记录。语法是:
```sql
DELETE FROM table_name
WHERE condition;
```
下面是从表中删除Id 3记录的示例
```sql
DELETE FROM Person
WHERE Id = 3;
```
使用DELETE删除给定表中的所有记录
```sql
DELETE * FROM Person
;
```
或者根据您的RDBMS您可以使用TRUNCATE TABLE语句删除表中的所有记录并且根据您的RDBMS可能允许或不允许回滚。 DELETE是DMLTRUNCATE是DDL。
```sql
TRUNCATE TABLE Person;
```