本文介绍了IDENT_CURRENT和空表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 可以有人解释一下,为什么空表中的IDENT_CURRENT是1? 插入第一条记录后它仍然是1 (假设起始值 为1)这没关系。但是如果我从新创建的 表中检查IDENT_CURRENT,结果应该是NULL,还是不是? 再见, 赫尔穆特 解决方案 NULL值是什么意思?为什么不零?记住IDENTITY是专有的和非关系的,所以它可以做任何想做的事情。 想想如果你有一个1950年代的顺序磁带文件它将如何工作系统。计数器从1开始,在插入之后而不是之前递增。它是maganeitc磁带机的读/写磁头的位置。 我们有NULL来标记未知的东西。为什么不使用它? 在手册中,IDENT_CURRENT被描述为给出最后生成的 标识值。因此,从我的逻辑角度来看,如果它之前没有生成一个值,它就无法返回值。并且因为零可以是有效的 起始值,所以它不能回零。 也许我们有一个IDENT_NEXT显示下一个值,而不是IDENT_CURRENT。这可以避免这种误解。 再见, 赫尔穆特 Hi,can somebody explain me, why the IDENT_CURRENT from an empty table is 1?After insert of the first record it is still 1 (assuming that start valueis 1) which is okay. But if i check the IDENT_CURRENT from a newly createdtable the result should be NULL, or not?bye,Helmut 解决方案 What would a NULL value mean? Why not zero? Remember IDENTITY is proprietary and non-relational, so it can do anything it wants. Think about how it would work if you had a 1950''s sequential tape file system. The counter starts at one and is incremented after the insertion instead of before. It is the position of the read/write head of the maganeitc tape drive.We have NULL to mark something as unknown. Why not using it?In the manual IDENT_CURRENT is described as "gives back the last generatedident value". So from my logical point of view it cannot give back a valueif it has not generated a value before. And because zero can be a validstarting value it can''t give back zero.Maybe it would be better we have a IDENT_NEXT which shows the next valuewhich will be used, instead of IDENT_CURRENT. This could avoid suchmisconception.bye,Helmut 这篇关于IDENT_CURRENT和空表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-22 14:06