SQLite中的主键是否需要索引?

前端之家收集整理的这篇文章主要介绍了SQLite中的主键是否需要索引?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当一个整数列在sqlite表中被标记为主键时,是否应该为它创建一个索引? sqlite似乎不会自动为主键列创建索引,但也许它索引它,无论如何,给定其目的? (我将始终在该列上搜索)。

字符串主键的情况会有什么不同吗?

It does it for you.

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相关文章