Return deleted rows in sqlite

两盒软妹~` 提交于 2020-01-14 22:29:09

问题


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

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

I tried to do:

DELETE OUTPUT DELETED.*
FROM table
WHERE clause

But I have an error:

SQLite exception: near "OUTPUT": syntax error

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


回答1:


The DELETE statement has no OUTPUT clause.

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

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



来源:https://stackoverflow.com/questions/43208274/return-deleted-rows-in-sqlite

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!