在sqlite中返回已删除的行 [英] Return deleted rows in sqlite

查看:34
本文介绍了在sqlite中返回已删除的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先执行两个查询,例如 SELECT * FROM TABLE WHERE 子句DELETE * FROM TABLE WHERE 子句,效率不高.

It's not efficient to do two queries like SELECT * FROM TABLE WHERE clause and then DELETE * FROM TABLE WHERE clause.

所以我想进行 DELETE 查询并返回已删除的行(一个查询).

So I want to make DELETE query and return deleted rows (one query).

我尝试这样做:

DELETE OUTPUT DELETED.*
FROM table
WHERE clause

但是我有一个错误:

SQLite exception: near "OUTPUT": syntax error

如何正确制作或者可能有另一种返回已删除行的替代方法?

How to make it correctly or maybe there is another alternative way to return deleted rows?

推荐答案

DELETE 语句有没有 OUTPUT 子句.

The DELETE statement has no OUTPUT clause.

执行SELECT后,所有重要数据都在缓存中,因此DELETE会运行得很快.

After doing the SELECT, all the important data is in the cache, so the DELETE will run quickly.

因为 SELECT 加 DELETE 是唯一的方式,所以它是最有效的方式.

And because SELECT plus DELETE is the only way, it is the most efficient way.

这篇关于在sqlite中返回已删除的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆