<tfoot id='FIY73'></tfoot>
  1. <small id='FIY73'></small><noframes id='FIY73'>

        <bdo id='FIY73'></bdo><ul id='FIY73'></ul>
    1. <legend id='FIY73'><style id='FIY73'><dir id='FIY73'><q id='FIY73'></q></dir></style></legend>

      <i id='FIY73'><tr id='FIY73'><dt id='FIY73'><q id='FIY73'><span id='FIY73'><b id='FIY73'><form id='FIY73'><ins id='FIY73'></ins><ul id='FIY73'></ul><sub id='FIY73'></sub></form><legend id='FIY73'></legend><bdo id='FIY73'><pre id='FIY73'><center id='FIY73'></center></pre></bdo></b><th id='FIY73'></th></span></q></dt></tr></i><div id='FIY73'><tfoot id='FIY73'></tfoot><dl id='FIY73'><fieldset id='FIY73'></fieldset></dl></div>

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

      时间:2023-10-25

        <small id='riNQR'></small><noframes id='riNQR'>

      1. <tfoot id='riNQR'></tfoot>
              <legend id='riNQR'><style id='riNQR'><dir id='riNQR'><q id='riNQR'></q></dir></style></legend>
                <bdo id='riNQR'></bdo><ul id='riNQR'></ul>
                  <tbody id='riNQR'></tbody>
                <i id='riNQR'><tr id='riNQR'><dt id='riNQR'><q id='riNQR'><span id='riNQR'><b id='riNQR'><form id='riNQR'><ins id='riNQR'></ins><ul id='riNQR'></ul><sub id='riNQR'></sub></form><legend id='riNQR'></legend><bdo id='riNQR'><pre id='riNQR'><center id='riNQR'></center></pre></bdo></b><th id='riNQR'></th></span></q></dt></tr></i><div id='riNQR'><tfoot id='riNQR'></tfoot><dl id='riNQR'><fieldset id='riNQR'></fieldset></dl></div>

              • 本文介绍了SQLite 中的主键是否需要索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                当一个整数列在 SQLite 表中被标记为主键时,是否也应该为它显式创建索引?SQLite 似乎不会自动为主键列创建索引,但鉴于其目的,它可能无论如何都会对其进行索引?(我会一直在那个专栏上搜索)

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

                解决方案

                它为您做到了.

                一个>

                <块引用>

                INTEGER PRIMARY KEY 列放在一边,UNIQUE 和 PRIMARY KEY约束是通过在数据库中创建索引来实现的(在与CREATE UNIQUE INDEX"语句相同的方式).这样一个索引像数据库中的任何其他索引一样用于优化查询.因此,通常没有优势(但显着的开销)在一组已经存在的列上创建索引共同受 UNIQUE 或 PRIMARY KEY 约束.

                When an integer column is marked as a primary key in an SQLite table, should an index be explicitly created for it as well? SQLite does not appear to automatically create an index for a primary key column, but perhaps it indexes it anyway, given its purpose? (I will be searching on that column all the time).

                Would the situation be any different for a string primary key?

                解决方案

                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 中的主键是否需要索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Varchar 上的索引是否会对性能产生影响? 下一篇:如何在 MySQL 中为多对多连接正确索引链接表?

                相关文章

                <i id='WFgUi'><tr id='WFgUi'><dt id='WFgUi'><q id='WFgUi'><span id='WFgUi'><b id='WFgUi'><form id='WFgUi'><ins id='WFgUi'></ins><ul id='WFgUi'></ul><sub id='WFgUi'></sub></form><legend id='WFgUi'></legend><bdo id='WFgUi'><pre id='WFgUi'><center id='WFgUi'></center></pre></bdo></b><th id='WFgUi'></th></span></q></dt></tr></i><div id='WFgUi'><tfoot id='WFgUi'></tfoot><dl id='WFgUi'><fieldset id='WFgUi'></fieldset></dl></div>
                  <bdo id='WFgUi'></bdo><ul id='WFgUi'></ul>

                <tfoot id='WFgUi'></tfoot>
              • <small id='WFgUi'></small><noframes id='WFgUi'>

                <legend id='WFgUi'><style id='WFgUi'><dir id='WFgUi'><q id='WFgUi'></q></dir></style></legend>