sqlite:在事务中删除表? [英] sqlite: dropping a table in a transaction?
问题描述
我有一个简单的单表 sqlite3 数据库文件,它只有一个表.没有钥匙,外国的或国内的.没有触发器.我有以下工作流程:
I have a simple, single table sqlite3 database file that has exactly one table. There are no keys, foreign or domestic. There are no triggers. I have the following workflow:
如果数据库文件存在打开它.
If the database file exixts open it.
- 开始独家交易
- 按顺序选择表中的所有行.
- 对每一行进行操作.
- 删除每个操作过的行.
- 完成后,计算表中剩余的行数,如果为 0,则 DROP 表然后取消链接数据库文件
- 提交或回滚事务
删除表总是失败并显示表被锁定的消息.我已经看到其他一些帖子表明可能存在开放语句句柄或其他杂物.由于我使用sqlite_exec()"来完成所有这些操作,因此除了数据库句柄本身之外,我没有任何打开的数据库.
The drop-table always fails with the message that the table is locked. I've seen a couple of other posts that suggest that there could be open statement handles or other cruft lying around. Since I am using "sqlite_exec()"s for all of this I do not have any open DB anything except the DB handle itself.
事务中不允许删除表吗?
Is drop table not allowed in transactions?
推荐答案
删除表时,当表上仍有一些活动光标时,即当您没有完成一个表时,您会收到表被锁定"消息语句(或者没有关闭您使用的任何语言的查询对象).
When dropping a table, you get the "table is locked" message when there is still some active cursor on the table, i.e., when you did not finalize a statement (or did not close a query object in whatever language you're using).
这篇关于sqlite:在事务中删除表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!