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

      <legend id='nyvxP'><style id='nyvxP'><dir id='nyvxP'><q id='nyvxP'></q></dir></style></legend>
      <tfoot id='nyvxP'></tfoot>

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

        自增唯一标识符

        时间:2023-07-18
          <tbody id='hxeRo'></tbody>

          1. <small id='hxeRo'></small><noframes id='hxeRo'>

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

                  <legend id='hxeRo'><style id='hxeRo'><dir id='hxeRo'><q id='hxeRo'></q></dir></style></legend>
                • 本文介绍了自增唯一标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  基本上我想以与身份类似的方式使用 uniqueidentifier.我不想在其中插入值,它应该只是自动插入值,每行不同的值.我无法在类型为 uniqueidentifier 的列上设置自动增量(属性自动增量"设置为 false 且不可编辑).

                  Basically I want to use uniqueidentifier in similar way as identity. I don't want to insert values into it, It should just insert values automatically, different value for each row. I'm not able to set autoincrement on columns of type uniqueidentifier(the property 'autoincrement' is set to false and is not editable).

                  推荐答案

                  或者更好:使用 newsequentialid() 作为 UNIQUEIDENITIFER 列的默认值.这将为您提供一系列有点顺序的 GUID.

                  Or even better: use the newsequentialid() as the default for your UNIQUEIDENITIFER column. That'll give you a somewhat sequential series of GUIDs.

                  CREATE TABLE dbo.YourTable   
                     (SerialID UNIQUEIDENTIFIER 
                          CONSTRAINT DF_SerialID DEFAULT newsequentialid(),
                       .... (other columns)......
                     )
                  

                  问题是:newsequentialid 可用作列默认值 - 您不能将其作为函数或任何东西调用.但这似乎符合您的要求.

                  Trouble is: newsequentialid is only available as a column default - you cannot call it as a function or anything. But that seems to fit your requirements.

                  更新:似乎在 SQL Server Management Studio 中存在一个公认的错误,该错误阻止将 newsequentialid() 指定为交互式表设计器中列的默认值.

                  UPDATE: there appears to be an acknowledged bug in SQL Server Management Studio that prevents specifying newsequentialid() as the default for a column in the interactive table designer.

                  请参阅:http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/cad8a4d7-714f-44a2-adb0-569655ac66e6

                  解决方法:创建您的表而不指定任何默认值,然后在正常查询窗口中输入此 T-SQL 语句并运行它:

                  Workaround: create your table without specifying any default, and then type in this T-SQL statement in a normal query window and run it:

                  ALTER TABLE dbo.YourTable
                      ADD CONSTRAINT DF_SerialID DEFAULT newsequentialid() FOR SerialID
                  

                  这应该可以解决问题!

                  这篇关于自增唯一标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MySQL:选择语句中的自动增量临时列 下一篇:如何使用另一个表中的 MAX 值重置 MySQL AutoIncrement?

                  相关文章

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

                    1. <small id='sZYsT'></small><noframes id='sZYsT'>

                    2. <legend id='sZYsT'><style id='sZYsT'><dir id='sZYsT'><q id='sZYsT'></q></dir></style></legend>

                    3. <tfoot id='sZYsT'></tfoot>
                      • <bdo id='sZYsT'></bdo><ul id='sZYsT'></ul>