发布网友 发布时间:2022-05-03 01:59
共3个回答
懂视网 时间:2022-05-03 06:21
If we are not interested in this so called feature, then we can do two things to stop that jump.
First, we need to remove Identity
column from tables. Then create a sequence without cache feature and insert number from that sequence. The following is the code sample:
CREATE SEQUENCE Id_Sequence AS INT START WITH 1 INCREMENT BY 1 MINVALUE 0 NO MAXVALUE NO CACHE insert into MyTestTable values(NEXT VALUE FOR Id_Sequence, ‘Mr.Tom‘); insert into MyTestTable values(NEXT VALUE FOR Id_Sequence, ‘Mr.Jackson‘);
Open SQLServer configuration manager from your server. Select SQL Server 2012 instance there right client and select Properties menu. You will find a tabbed dialog window. You select start up parameters tab from there and register -t272. Then restart SQL Server 2012 instance again and see the difference:
打开SQLServer configuration manager。左边选择服务。右边在对应实例右键选择属性。点击启动参数。把-t272添加进去。重启sqlserver服务。再次新增数据进行观察。
If too many tables contain identity column to your database and all contain existing values, then it is better to go for solution 2. Because it is a very simple solution and its scope is server wise. This means if you add SQL Server 2012 parameter -t272 there, then it will affect all your databases there. If you want to create a new database and you need auto generated number field, then you can use solution 1, that means use sequence value to a column instead of auto Identity value. There are so many articles you can find online about when you will use auto identity column when using sequence and advantages/disadvantages of each other. I hope you will read all those and take the appropriate decision.
如果您的数据库表包含太多的标识列,并且所有的表都包含现有的值,那么最好是去用解决方案2。因为它是一个非常简单的解决方案,它的范围是服务器。这意味着如果你添加SQL Server 2012参数- t272,然后它会影响你所有的数据库里。
如果你想创建一个新的数据库,你需要自动生成的数字字段,那么你可以使用解决方案1,这意味着使用序列值的列,而不是自动识别值。
有这么多的文章,你可以找到网上关于当你将使用自动识别列时,使用序列和优势/劣势的对方。我希望你会阅读所有这些,并采取适当的决定。
转:SqlServer2012自增列值突然增大1000的原因及解决方法
标签:back sdn rod 回滚 startup cas sqlserver div 一个
热心网友 时间:2022-05-03 03:29
ID设为自增列,如果你删除了一些数据,ID是不会从你删除那个ID的值开始从新计算的,只会一直递增,如你创建了三条数据,ID分别为1,2,3,当你删除ID为3的数据后,再新建一条,那么这个ID的值就为4追问对的 ! 请问如何删除自增呢?追答
选择ID主键,将标识改为否
热心网友 时间:2022-05-03 04:47
可能你之前删除了一些行的数据追问只有32行数据,仔细的看了看,都是1到32都是在的