唯一标识符列Sql [英] unique identifier column Sql

查看:350
本文介绍了唯一标识符列Sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个sql db表,其中我的主键列具有数据类型唯一标识符.但是当我尝试填充表时,它不会自动填充并且没有像身份规范这样的选项.如何使用唯一标识符数据类型列自动生成ID也是表的主键.

谢谢
Amit

hey everyone,

I have a sql db table in which my primary key column has data type unique identifier.But when i try to fill table,its not filled automatically and there is no option like identity specification.How is Id automatically generated with unique identifier data type column.It is also primary key of table.

Thanks
Amit

推荐答案

为此,您需要进行一些手工工作.

如果要通过SSMS创建表,请执行以下步骤.

  • 使用UniqueIdentifier 数据类型创建列
For that you need some manual work.

If you are creating table from SSMS then follow these step.

  • Create column with UniqueIdentifier Datatype
  • 内部列属性
  • 找到默认值或绑定属性
  • 将其值写入(newsequentialid())
CREATE TABLE NEWSEQUENTIALID_TEST
(
ID UNIQUEIDENTIFIER DEFAULT NEWSEQUENTIALID() PRIMARY KEY,
TESTCOLUMN CHAR(2000) DEFAULT REPLICATE('X',2000)
)



它可能在保存表时警告您,但会忽略并保存.

现在,您会发现将自动生成唯一的标识符.

如果有帮助,请 投票 接受答案 .



It may warn you while saving table but ignore and save.

Now you will find that unique Identifier will be automatically generated.

Please vote and Accept Answer if it Helped.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆