在SQLite中索引视图

Mig*_*uel 15 sqlite

有什么办法可以在SQLite中为视图构建索引吗?

Ste*_*end 14

来自频繁的在线SQLite评论者的这个帖子说不:

>Hi
>
>May I know if we can create index on a View?

You can't create an index on a VIEW.
A VIEW can be seen as a stored SELECT statement. 

>Thanks in advance.
>wying
-- 
( Kees Nuyt
)
Run Code Online (Sandbox Code Playgroud)

  • 奇怪的是,我在我的日志中看到,sqlite将自动为封面下的视图创建索引,具体取决于使用情况! (3认同)

Mit*_*eat 6

如果这些索引符合选择和过滤条件,则访问视图将使用视图中基础表上定义的索引.

因此,即使您无法在SQlite视图上定义索引,表索引仍可能是合适的.

  • @Miguel 因为它不满足[子查询扁平化条件](https://www.sqlite.org/optoverview.html#flattening)。 (3认同)