[英]Create table with UNIQUEIDENTIFIER as PK
I have been trying (unsuccessfully) to create a table with a UNIQUEIDENTIFIER
as the primary key. 我一直在尝试(未成功)创建一个以
UNIQUEIDENTIFIER
作为主键的表。 The script below will create the table just fine, however there is no PK specified. 下面的脚本可以很好地创建表,但是未指定PK。 This is my first time using a UNIQUEIDENTIFIER, however.
但是,这是我第一次使用UNIQUEIDENTIFIER。 Any ideas?
有任何想法吗?
T-SQL T-SQL
CREATE TABLE [dbo].[AgentRelationshipCodes]
(
Id UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(),
RelationshipId char(3) NULL,
EffectiveDate datetime NULL,
LastChangeDate datetime NOT NULL,
LastChangeId char(6) NOT NULL,
AgtTableId int FOREIGN KEY REFERENCES AgentTransmission(ID)
);
Management Studio 管理工作室
"
create table [dbo].[AgentRelationshipCodes]
(
ID uniqueidentifier not null primary key default newid(),
.
.
.
)
Repeat for the other tables.
"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.