在sqlite中返回已删除的行

编程入门 行业动态 更新时间:2024-10-26 06:30:23
本文介绍了在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中返回已删除的行

本文发布于:2023-10-24 09:48:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523619.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:sqlite

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!