Sybase newid()
来源:互联网 发布:python 正则匹配 编辑:程序博客网 时间:2024/04/29 18:04
Chapter 2: Transact-SQL Functions
newid
Description
Generates human-readable, globally unique IDs (GUIDs) in two different formats, based on arguments you provide. The length of the human-readable format of the GUID value is either 32 bytes (with no dashes) or 36 bytes (with dashes).
Syntax
newid([optionflag])
Parameters
- option flag
0, or no value – the GUID generated is human-readable (varchar), but does not include dashes. This argument, which is the default, is useful for converting values into varbinary.
-1 – the GUID generated is human-readable (varchar) and includes dashes.
-0x0 – returns the GUID as a varbinary.
Any other value for newid returns NULL.
Examples
Example 1
Creates a table with varchar columns 32 bytes long, then uses newid with no arguments with the insert statement:
create table t (UUID varchar(32))goinsert into t values (newid())insert into t values (newid())goselect * from t
UUID--------------------------------f81d4fae7dec11d0a76500a0c91e6bf6 7cd5b7769df75cefe040800208254639
Example 2
Produces a GUID that includes dashes:
select newid(1)
------------------------------------b59462af-a55b-469d-a79f-1d6c3c1e19e3
Example 3
Returns a new GUID of type varbinary for every row that is returned from the query:
select newid(0x0) from sysobjects
Example 4
Uses newid with the varbinary datatype:
sp_addtype binguid, "varbinary(16)"create default binguid_dfltas newid(0x0)sp_bindefault "binguid_dflt","binguid"create table T1 (empname char(60), empid int, emp_guid binguid)insert T1 (empname, empid) values ("John Doe", 1)insert T1 (empname, empid( values ("Jane Doe", 2)
Usage
newid generates two values for the globally unique ID (GUID) based on arguments you pass to newid. The default argument generates GUIDs without dashes. By default newid returns new values for every filtered row.
You can use newid in defaults, rules, and triggers, similar to other functions.
Make sure the length of the varchar column is at least 32 bytes for the GUID format without dashes, and at least 36 bytes for the GUID format with dashes. The column length is truncated if it is not declared with these minimum required lengths. Truncation increases the probability of duplicate values.
An argument of zero is equivalent to the default.
Because GUIDs are globally unique, they can be transported across domains without generating duplicates.
Standards
ANSI SQL – Compliance level: Transact-SQL extension.
Permissions
Any user can execute newid.
- Sybase newid()
- sql Newid
- SYBASE
- sybase
- sybase
- SYBASE
- sybase
- sybase
- sybase
- sybase
- NEWID (Transact-SQL)
- 理解newid()和newsequentialid()
- sql newid()随机函数
- T_SQL NEWID()用法
- newid() 和row_number()
- sql newid()随机函数
- Exists,Datediff,Newid,
- sql newid()随机函数
- c++软件开发第三方库大全
- 自己做的一个腾讯微博客户端
- Spool缓冲池技术导出oracle数据为文本文件
- C++ 内存池 -- C++ Memory Pool
- android系统开发(六)-HAL层开发基础
- Sybase newid()
- bug追踪管理工具mantis
- Flex Builder 3 和 Flash Builder 4 官网下载、安装与注册
- 淘宝的可伸缩高性能互联网架构
- 用Log4Net在ASP.net中建立应用程序日志
- 晶晶小妹的个人空间
- select SCOPE_IDENTITY()
- C#键盘事件控制只能输入数字
- 查询和删除表中重复数据sql语句