如何在SQL Server 2008中使用GUID数据类型 [英] how can I use GUID datatype in SQL Server 2008
本文介绍了如何在SQL Server 2008中使用GUID数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,先生,
我听说过GUID,并且我有点理解它是一种数据类型,但是我不能使用它
你能告诉我使用它的方法吗?
顺便说一句,可以说我想要这样的东西:
Hello Sir,
I heared about GUID and I kind of understood that its a data type , But I couldn''t use it
could you please show me the way to use it ...
by the way , lets say I want something like this :
CREATE TABLE Employees ( ID guid PRIMARY KEY, Name NVARCHAR(50) NOT NULL )
推荐答案
guid的数据类型为uniqueIdentifier
,因此您的DDL应该类似于:
The data type for guid isuniqueIdentifier
so your DDL should be something like:
CREATE TABLE Employees ( ID uniqueidentifier PRIMARY KEY, Name NVARCHAR(50) NOT NULL ).
请参阅: uniqueidentifier(Transact-SQL) [
See: uniqueidentifier (Transact-SQL)[^]
您可以使用SQL Server 2008中的
Hi,
you can generate unique GUID using
select NEWID();
生成唯一的GUID.并使用uniqueIdentifier数据类型可以存储它(如迈克所说)
谢谢
-amit.
from SQL server 2008. and using uniqueIdentifier datatype you can store it (as Mike said)
thanks
-amit.
这篇关于如何在SQL Server 2008中使用GUID数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文