首页>>帮助中心>>VPS服务器sqlserver,建主键-索引唯一键语句

VPS服务器sqlserver,建主键-索引唯一键语句

2024/12/17 24次

VPS服务器sqlserver,建主键-索引唯一键语句

--建主键ALTER TABLE [dbo].[t_test] ADD CONSTRAINT [PK_t_test] PRIMARY KEY CLUSTERED ( [id] ASC)WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]--删主键IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[t_test]') AND name = N'PK_t_test')ALTER TABLE [dbo].[t_test] DROP CONSTRAINT [PK_t_test]--建索引CREATE NONCLUSTERED INDEX [t_test_index] ON [dbo].[t_test] ( [v1] ASC, [v2] ASC, [v3] ASC, [v4] ASC)WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]--删除索引DROP INDEX [t_test_index] ON [dbo].[t_test] WITH ( ONLINE = OFF )--建唯一键ALTER TABLE [dbo].[t_test] ADD CONSTRAINT [t_test_unique] UNIQUE NONCLUSTERED ( [v1] ASC, [v2] ASC, [v3] ASC)WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]--删除唯一键IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[t_test]') AND name = N't_test_unique')ALTER TABLE [dbo].[t_test] DROP CONSTRAINT [t_test_unique]

购买使用一诺网络日本vps,可以极大降低初创企业、中小企业以及个人开发者等用户群体的整体IT使用成本,无需亲自搭建基础设施、简化了运维和管理的日常工作量,使用户能够更专注于自身的业务发展和创新。日本vps低至129元/月,购买链接:https://www.enuoidc.com/vpszq.html?typeid=10