The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

DELETE Statement

Last updated: 2024-08-22 17:02:21

Conditional Deletion

```sql
select * from tbase;
id
nickname
2
TBase is good
1
Hello TBase
3

4
TBase good
delete from tbase where id=4;
Null Condition Expression
delete from tbase where nickname is null;
select * from tbase;
id
nickname
2
TBase is good
1
Hello TBase

Multi-table Join Data Deletion

set prefer_olap to on;
delete from tbase using t_appoint_col where tbase.id=t_appoint_col.id;
select * from tbase;
id
nickname
2
TBase is good

Return Deleted Data

delete from tbase returning *;
id
nickname
2
TBase is good

Delete All Data

insert into tbase select t,random()::text from generate_series(1,100000) as t;
truncate table tbase;