SQL Server中的uniqueidentifier类型
uniqueidentifier类型可以配合T-SQL中的newid和newsequentialid来生成唯一标识符,具体区别如下(摘抄自微软官方文档)。
Nonsequential GUIDs: You can generate nonsequential global unique identifiers to be stored in an attribute of a UNIQUEIDENTIFIER type. You can use the T-SQL function NEWID to generate a new GUID, possibly invoking it with a default expression attached to the column. You can also generate one from anywhere. for example, the client by using an application programming interface (API) that generates a new GUID. The GUIDs are guaranteed to be unique across space and time.
Sequential GUIDs: You can generate sequential GUIDs within the machine by using the T-SQL function NEWSEQUENTIALID.
测试代码:
create table t_1(
id uniqueidentifier ROWGUIDCOL primary key default NEWSEQUENTIALID(),
value int
)
create table t_2(
id uniqueidentifier ROWGUIDCOL primary key default NEWID(),
value int
) insert into t_1(value) values (1)
insert into t_1(value) values (2)
insert into t_1(value) values (3)
insert into t_1(value) values (4)
insert into t_1(value) values (5) insert into t_2(value) values (1)
insert into t_2(value) values (2)
insert into t_2(value) values (3)
insert into t_2(value) values (4)
insert into t_2(value) values (5) select *,rowguidcol from t_1
select *,rowguidcol from t_2

SQL Server中的uniqueidentifier类型的更多相关文章
- delphi 转换sql server 中的 bit类型
FieldByName('e').AsBoolean = false 其中e为 sql server 中的bit类型.
- 浅析SQL Server 中的SOS_SCHEDULER_YIELD类型的等待
本文出处:http://www.cnblogs.com/wy123/p/6856802.html 进程的状态转换 在说明SOS_SCHEDULER_YIELD等待之前,先简要介绍一下进程的状态(迷迷糊 ...
- C#操作SQL Server中的Image类型数据
该例子是一个对SQL Server数据类型的一个操作例子,具有写入.读取功能. 1:准备数据库 1)创建数据库 Test 2)创建表 Table_1 (分别有2个字段:id(Int).photo(Im ...
- 在Sql Server中使用Guid类型的列及设置Guid类型的默认值
1.列的类型为uniqueidentifier 2.列的默认值可以设为newid()
- .SQL Server中 image类型数据的比较
原文:.SQL Server中 image类型数据的比较 在SQL Server中如果你对text.ntext或者image数据类型的数据进行比较.将会提示:不能比较或排序 text.ntext 和 ...
- SQL SERVER中LIKE使用变量类型输出结果不同
前言:Sql Server中LIKE里面使用不同的变量类型导致查询结果不一致的问题,其实看似有点让人不解的现象背后实质跟数据类型的实现有关. 一.我们先来创建示例演示具体操作 CREATE TABLE ...
- SQL Server中的GUID
GUID(Global unique identifier)全局唯一标识符,它是由网卡上的标识数字(每个网卡都有唯一的标识号)以及 CPU 时钟的唯一数字生成的的一个 16 字节的二进制值. GUID ...
- sql server中常用方法函数
SQL SERVER常用函数 1.DATEADD在向指定日期加上一段时间的基础上,返回新的 datetime 值. (1)语法: DATEADD ( datepart , number, date ) ...
- SQL Server中的RAND函数的介绍和区间随机数值函数的实现
工作中会遇到SQL Server模拟数据生成以及数值列值(如整型.日期和时间数据类型)随机填充等等任务,这些任务中都要使用到随机数.鉴于此,本文将对SQL Server中随机数的使用简单做个总 ...
随机推荐
- org.apache.struts2.json.JSONWriter can not access a member of class
偶遇一个问题:org.apache.struts2.json.JSONWriter can not access a member of class org.apache.tomcat.dbcp.db ...
- Maven问题总结:could not resolve archetype xxxxxxx from any of the configured repositories
错误提示 Eclipse中通过Archetype创建Maven项目时报错:Could not resolve archetype xxxxxxx from any of the configured ...
- Myeclipse 多版本共存
Myeclipse2015 stable2.0 和Myeclipse10 共存的解决办法: 1. 准备内容: 1) myeclipse-2015-stable-2.0-offline-installe ...
- mysq数据库再次理解
1.表中的一条记录就是一个object,object有很多属性,对应表中的字段.object的属性对应的值就是字段值 2.外键是关联表关系用的.表关系的确立只能通过外键 但更高效的策略是,在数据库中部 ...
- centos7 安装mysql5.7及配置
一.Mysql 各个版本区别:1.MySQL Community Server 社区版本,开源免费,但不提供官方技术支持.2.MySQL Enterprise Edition 企业版本,需付费,可以试 ...
- php获得网站根目录的几个方法
php获得网站根目录的几个方法 电脑软硬件应用网 45IT.COM 时间:2015-01-08 12:54 作者:佚名 在php中我们要得到网站根目录可以用很多全局变量实现了,如可以利用__file_ ...
- 理解OAuth 2.0[摘]
原文地址:http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html OAuth是一个关于授权(authorization)的开放网络标准,在全世界得到 ...
- Programming In hardware Programming in software
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION
- changing a pointer rather than erasing memory cells
Computer Science An Overview _J. Glenn Brookshear _11th Edition In a data structure based on a point ...
- GPG操作——签名验证
问题描述: 可能大家都遇到过软件在下载过程中由于网络原因导致下载的软件体积与实际软件体积不符.最常见的办法是对待下载文件附加一个摘要文件.这种做法比较常见,也比较容易实现.但是,还是会有一个问题:如果 ...