SQL Server中的uniqueidentifier类型
2016-01-13 16:03
316 查看
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.
测试代码:
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
相关文章推荐
- 当前uistatusBar前景为白色,当增加uiwindow后,uistatusBar变为黑色的解决方法
- duilib学习记录之创建自定义控件
- 205,UIWindow
- valueForKeyPath计算求和、平均值、最大、最小
- 软件测试_BadBoy自动化测试工具3_创建suites、tests、steps和Template
- easyui datagrid动态绑定列名和数据
- 获取手机信息(UIDevice、NSBundle、NSLocale)
- NSBundle、UIImageView和UIButton对比、Xcode文档安装路径、Xcode模拟器安装路径
- UITableView - 全面解析
- UIView的常见属性
- pt-query-digest 官方解释
- UIView - (shadowColor &shadowOffset & shadowOpacity & shadowRadius)属性
- StringBuilder与StringBuffer的区别
- 获取当前页面所在的controller
- easyui calendar修改显示周
- Easyui form combobox省市区三级联动
- uitableview刷新指定section 或 刷新指定 cell (ios)
- request和requestScope的区别
- break、continue、return之间的区别与联系
- IOS UICollectionView didselect促发不到