10-SQLite之创建索引(sql create index)

前端之家收集整理的这篇文章主要介绍了10-SQLite之创建索引(sql create index)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、索引的概述

例如这样一个查询:select * from table1 where id=10000。如果没有索引,必须遍历整个表,直到ID等于10000的这一行被找到为止;有了索引之后(必须是在ID这一列上建立的索引),即可在索引中查找。由于索引是经过某种算法优化过的,因而查找次数要少的多。

二、create index实例:

本例会创建一个简单的索引,名为 "personsindex",在 persons表的 id列:
create index personsindex on persons(id);

如果您希望以降序索引某个列中的值,您可以在列名称之后添加保留字 desc:
create index personsindex on persons(id desc);

假如您希望索引不止一个列,您可以在括号中列出这些列的名称,用逗号隔开:
create index personsindex on persons(id,name);
原文链接:https://www.f2er.com/sqlite/199702.html

猜你在找的Sqlite相关文章