• <legend id='CzTIE'><style id='CzTIE'><dir id='CzTIE'><q id='CzTIE'></q></dir></style></legend>

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

        <bdo id='CzTIE'></bdo><ul id='CzTIE'></ul>
      <tfoot id='CzTIE'></tfoot>
      1. <small id='CzTIE'></small><noframes id='CzTIE'>

      2. Sql Server 唯一键也是索引吗?

        时间:2023-10-25
        <legend id='lUgHU'><style id='lUgHU'><dir id='lUgHU'><q id='lUgHU'></q></dir></style></legend>

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

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

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

                <tbody id='lUgHU'></tbody>
              <tfoot id='lUgHU'></tfoot>

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

                  问题描述

                  我在表中有一列(例如用户名),我想确保它是唯一的.因此,我为该列创建了一个唯一键并将其命名为 IX_Users_UserName.

                  现在,如果我根据用户名进行大量用户搜索,我想确保该字段有索引.

                  我是否需要创建单独的索引,还是唯一键也被视为索引,就像主键是聚集唯一键一样?

                  解决方案

                  唯一键:唯一键强制执行它们所在的列的唯一性被定义.唯一键创建一个列上的非聚集索引.唯一键只允许一个 NULL 值.

                  Alter table 添加唯一约束到列:

                  ALTER TABLE 作者添加约束IX_Authors_Name UNIQUE(Name) GO

                  来源

                  更多信息来自 MSDN.>

                  FWIW -- 如果您的约束没有创建索引,我会避免将其命名为 IX_,因为这通常被认为与一个 (IX = Index) 相关联.

                  I've got a column in a table (eg. UserName) which I want to make sure is unique. So I create a unique key for that column and call it IX_Users_UserName.

                  Now, if I do lots of searching for users based on their username I want to make sure there is an index for that field.

                  Do I need to create a separate index, or is the unique key also considered an index, just like the primary key is a clustered unique key?

                  解决方案

                  Unique Key: Unique Key enforces uniqueness of the column on which they are defined. Unique Key creates a non-clustered index on the column. Unique Key allows only one NULL Value.

                  Alter table to add unique constraint to column:

                  ALTER TABLE Authors ADD CONSTRAINT IX_Authors_Name UNIQUE(Name) GO

                  Source

                  More information from MSDN.

                  FWIW -- if your constraint doesn't create an index, I would avoid naming it IX_ as that would typically be assumed to be associated with one (IX = Index).

                  这篇关于Sql Server 唯一键也是索引吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何重命名 MySQL 中的索引 下一篇:在 MySQL 中删除表也会删除索引吗?

                  相关文章

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

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