我怎样才能改变cloumn的incerement值 [英] How I can change the incerement value of cloumn
本文介绍了我怎样才能改变cloumn的incerement值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张桌子,有很多记录,我不能删除并重新创建它
我需要将Id列的增量值更改为2,旧值为1
这是我需要更改身份增量的表格的示例
创建 表 [dbo]。[相关](
[Id] [< span class =code-keyword> int ] IDENTITY ( 1 , 1 ) NOT NULL ,
[RELATEDDESC ] [ nvarchar ]( 50 )不 NULL ,
[USER_ID] [ int ] NULL ,
[ALTER_DATE] [datetime2]( 7 ) NULL ,
PRIMARY KEY < span class =code-keyword> CLUSTERED
(
[Id] ASC
) WITH (PAD_INDEX = OFF ,STATISTICS_NORECOMPUTE = OFF ,IGNORE_DUP_KEY = OFF ,ALLOW_ROW_LOCKS = ON ,ALLOW_PAGE_LOCKS = ON ) ON [ PRIMARY ]
) ON [ PRIMARY ]
GO
解决方案
尝试:
[Id] [ int ] IDENTITY ( 2 , 3 ) NOT NULL那将是从2开始,每次增加3:
2
5
8
...
I have a table and have a lot of records and i can't drop and recreate it
I need to change the increment value of the Id column to 2 the old value is 1
this is an example of the table I need to change the identity increment of
CREATE TABLE [dbo].[RELATED](
[Id] [int] IDENTITY(1,1) NOT NULL,
[RELATEDDESC] [nvarchar](50) NOT NULL,
[USER_ID] [int] NULL,
[ALTER_DATE] [datetime2](7) NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
解决方案
Try:
[Id] [int] IDENTITY(2,3) NOT NULLThat will start the value at 2, and increase it by 3 each time:
2 5 8 ...
这篇关于我怎样才能改变cloumn的incerement值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文