重置 PK 自动增量列
我已经多次导入数千条记录,以确保导入完美运行。
结果,现在当我在发布前进行实时导入时,自动增量列的 ID 列约为 300,000。
一旦我删除了这些表中的所有数据,是否有任何简单的方法可以“重置”此设置?我只想出于 SEO 的原因,URL:
Forum/1/Post
Forum/35/Post
Forum/5600/Post
看起来更好、更简洁(因此结果更可点击),而不是
Forum/300124/Post
Forum/370321/Post
Forum/450111/Post
我宁愿不删除该列并重新插入该列,因为它会破坏所有关系并意味着我会刷新我所有的数据上下文图等。
I've been importing thousands of records multiple times in an effort to get the import running perfectly.
As a result, now when I do the live import before release, the ID columns for the auto increment column are on around 300,000.
Is there any easy way to 'reset' this once I have deleted all the data from these tables? I only want to for SEO reasons, the URL:
Forum/1/Post
Forum/35/Post
Forum/5600/Post
Looks a lot nicer and more concise (therefore more clickable in results) than
Forum/300124/Post
Forum/370321/Post
Forum/450111/Post
I'd rather not delete the column and reinsert the column as it would ruin all relationships and mean I'd have to refresh all my data context diagrams etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要带有重新种子选项的
DBCC CHECKIDENT
命令,但我不确定它是否会改善 SEO。DBCC CHECKIDENT ("dbo.Table", RESEED, 0); --下一个 id 将为 1
http://msdn.microsoft. com/en-us/library/ms176057.aspx
You'll need the
DBCC CHECKIDENT
command with the reseed option, not sure I buy that it will improve SEO though.DBCC CHECKIDENT ("dbo.Table", RESEED, 0); --next id will be 1
http://msdn.microsoft.com/en-us/library/ms176057.aspx