<tfoot id='xDKIf'></tfoot>

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

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

      • <bdo id='xDKIf'></bdo><ul id='xDKIf'></ul>

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

      在 SQL Server 中,我应该为标识列创建索引,还是自动创建?

      In SQL Server, should I create an index for an identity column, or is it created automatically?(在 SQL Server 中,我应该为标识列创建索引,还是自动创建?)
    1. <tfoot id='SpxiU'></tfoot>
      • <bdo id='SpxiU'></bdo><ul id='SpxiU'></ul>

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

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

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

                  <tbody id='SpxiU'></tbody>
              • 本文介绍了在 SQL Server 中,我应该为标识列创建索引,还是自动创建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我相信当我创建一个 identity 列时,它会自动编入索引,但我不是 100% 确定.

                我应该为 identity 列创建索引,还是自动创建?

                解决方案

                create table test (Id int identity)去sp_help 测试

                <小时><前>对象test"没有任何索引,或者您没有权限.对象test"上没有定义约束,或者您没有权限.

                作为一般做法,您会在标识列上创建唯一索引,这会加快查找速度.

                通常您希望您的身份列也成为聚集索引"(Id int identity primary key 是快捷符号),这意味着表在磁盘上的排列顺序与您的身份相同列是.这对插入进行了优化,因为被插入的页面往往在内存中.在某些情况下,当您非常频繁地对表中的其他数据进行范围查找时,您可以考虑将其他列聚集在一起,因为 SQL Server 只允许每个表一个聚集索引.

                I believe when I create an identity column it gets indexed automatically, but I'm not 100% sure.

                Should I create an index for an identity column, or is it created automatically?

                解决方案

                create table test (Id int identity)
                go
                sp_help test
                


                The object 'test' does not have any indexes, or you do not have permissions.
                
                No constraints are defined on object 'test', or you do not have permissions.
                

                As a general practice you would create a unique index on your identity column, this speeds up lookups.

                Usually you would like your identity columns to be 'clustered indexes' as well (Id int identity primary key is the shortcut notation), meaning table is layed out on disk in the same order your identity column is. This optimizes for inserts, as the page being inserted into tends to be in memory. In some cases, when you are doing ranged lookups very frequently on other data in the table, you may consider clustering other columns instead, as SQL Server only allows you one clustered index per table.

                这篇关于在 SQL Server 中,我应该为标识列创建索引,还是自动创建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)(超出最大存储过程、函数、触发器或视图嵌套级别(限制 32))
                How to debug stored procedure in VS 2015?(如何在 VS 2015 中调试存储过程?)
                How to find a text inside SQL Server procedures / triggers?(如何在 SQL Server 程序/触发器中查找文本?)
                SQL Server stored procedure return code oddity(SQL Server 存储过程返回码奇怪)
                Conditional SQL ORDER BY ASC/DESC for alpha columns(alpha 列的条件 SQL ORDER BY ASC/DESC)
                Export stored procedure result set to Excel in SSMS(在SSMS中将存储过程结果集导出到Excel)
              • <tfoot id='cgG8Y'></tfoot>
                <i id='cgG8Y'><tr id='cgG8Y'><dt id='cgG8Y'><q id='cgG8Y'><span id='cgG8Y'><b id='cgG8Y'><form id='cgG8Y'><ins id='cgG8Y'></ins><ul id='cgG8Y'></ul><sub id='cgG8Y'></sub></form><legend id='cgG8Y'></legend><bdo id='cgG8Y'><pre id='cgG8Y'><center id='cgG8Y'></center></pre></bdo></b><th id='cgG8Y'></th></span></q></dt></tr></i><div id='cgG8Y'><tfoot id='cgG8Y'></tfoot><dl id='cgG8Y'><fieldset id='cgG8Y'></fieldset></dl></div>

                • <small id='cgG8Y'></small><noframes id='cgG8Y'>

                  <legend id='cgG8Y'><style id='cgG8Y'><dir id='cgG8Y'><q id='cgG8Y'></q></dir></style></legend>
                  • <bdo id='cgG8Y'></bdo><ul id='cgG8Y'></ul>

                            <tbody id='cgG8Y'></tbody>