SQLite database partitioning

[亡魂溺海] 提交于 2019-12-10 23:16:32

问题


I want to create sqlite partition structure, I created 3 databases, I attached those 3 databases to another database which will be parent with

ATTACH DATABASE '1.db' as 1
ATTACH DATABASE '2.db' as 2
ATTACH DATABASE '3.db' as 3

after i .quit the parent database the database attachments detach, How can I keep them attached even if I quit the database? Thanks.


回答1:


Attachments are never permanent.

Every program that opens the database needs to make any attachments it needs.

If you really think you need partitioning, using another database might be a better idea.




回答2:


Attachments are not permanent.

When partitioning a SQLITE database, the natural way to do it is to create a separate database for each X, where X is some element in the system that represents a query boundary that you don't need to cross.

For example, you can create a separate database for each user.

Or you can hash to 2 bytes on some key, and create a database for each pair of bytes, ameliorating lock contention.

If you don't have a natural partition in your data, and you need to scale beyond the capabilities of sqlite, you should consider another DB.



来源:https://stackoverflow.com/questions/28710861/sqlite-database-partitioning

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