about identity

brotherfromaq 2004-06-15 11:37:19
我在test数据库里有一个field设为identity
我现在把数据清空但是这个field不能从1开始,我该用什么命令使它从一开始。
...全文
63 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
futulove 2004-07-30
  • 打赏
  • 举报
回复
dbcc checkident(字段名,RESEED,开始的值)
victorycyz 2004-07-30
  • 打赏
  • 举报
回复

create table #T(a int identity(1,1),b int)

insert #t (b) select 1
union select 2

select * from #t

--用truncate:

truncate table #t

insert #t (b)select 3

select * from #t

drop table #t
victorycyz 2004-07-30
  • 打赏
  • 举报
回复

create table #T(a int identity(1,1),b int)

insert #t (b) select 1
union select 2

用truncate:

select * from #t

truncate table #t

insert #t (b)select 3

select * from #t

drop table #t
brotherfromaq 2004-07-30
  • 打赏
  • 举报
回复
up

22,206

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧