当整数列被标记为 SQLite 表中的主键时,是否也应该为其显式创建索引? SQLite 似乎不会自动为主键列创建索引,但考虑到它的用途,它可能无论如何都会对其进行索引? (我会一直搜索那个专栏)。
字符串主键的情况会有所不同吗?
最佳答案
INTEGER PRIMARY KEY columns aside, both UNIQUE and PRIMARY KEY constraints are implemented by creating an index in the database (in the same way as a "CREATE UNIQUE INDEX" statement would). Such an index is used like any other index in the database to optimize queries. As a result, there often no advantage (but significant overhead) in creating an index on a set of columns that are already collectively subject to a UNIQUE or PRIMARY KEY constraint.
关于sqlite - SQLite 中的主键是否需要索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3379292/