c#/.NET SQLite -- REINDEX 不起作用?
我正在尝试对使用 SQLite.NET 和 VS2008 创建的简单数据库中的表重新建立索引。我需要在每个 DELETE 命令后重新索引表,这是我编写的代码片段(它不起作用):
SQLiteCommand currentCommand;
String tempString = "REINDEX tf_questions";
//String tempString = "REINDEX [main].tf_questions";
//String tempString = "REINDEX main.tf_questions";
currentCommand = new SQLiteCommand(myConnection);
currentCommand.CommandText = tempString;
currentCommand.ExecuteNonQuery()
在我的程序中运行时,代码不会产生错误,但它也不会重新索引“tf_questions”表。在上面的示例中,您还会看到我尝试过的其他查询字符串也不起作用。
请帮忙,
谢谢
I'm trying to reindex a table in a simple database that I created using SQLite.NET and VS2008. I need to reindex tables after every DELETE command and here is the code snippet I have written (it does not work):
SQLiteCommand currentCommand;
String tempString = "REINDEX tf_questions";
//String tempString = "REINDEX [main].tf_questions";
//String tempString = "REINDEX main.tf_questions";
currentCommand = new SQLiteCommand(myConnection);
currentCommand.CommandText = tempString;
currentCommand.ExecuteNonQuery()
When run within my program, the code produces no errors, but it also doesn't reindex the "tf_questions" table. In the above example, you will also see the other query strings I've tried that also don't work.
Please help,
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了解决我的问题的方法。考虑以下代码:
尽管我希望使用内置的 SQL REINDEX 命令,但该代码可以工作。
I figured out a workaround for my problem. Consider the following code:
This code works, though I would have liked to have used the built-in SQL REINDEX command.
如果您这样做是为了性能,请考虑这个答案:
If you are doing this for the sake of performance, consider this answer: