SQL Server 中的 4 字节无符号整数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/306291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 00:18:50  来源:igfitidea点击:

4 byte unsigned int in SQL Server?

sqlsql-server-2005types

提问by Brian R. Bondy

Is there a 4 byte unsigned int data type in MS SQL Server?

MS SQL Server 中是否有 4 字节的 unsigned int 数据类型?

Am I forced to use a bigint?

我是否被迫使用 bigint?

采纳答案by Bill Karwin

It doesn't seem so.

似乎不是这样。

Here's an article describing how to create your own rules restricting an intto positive values. But that doesn't grant you positive values above 2^31-1.

这是一篇文章,描述了如何创建您自己的将 an 限制int为正值的规则。但这并不能赋予您以上的正值2^31-1

http://www.julian-kuiters.id.au/article.php/sqlserver2005-unsigned-integer

http://www.julian-kuiters.id.au/article.php/sqlserver2005-unsigned-integer

回答by Charles Bretana

Can you just add/subtract 2,147,483,648 (2^31) to the regular int ? (subtract on the way in, & add coming out) I know it sounds silly, but if you declare a custom datatype that does this, it's integer arithmetic and very fast.... It just won't be readable directly from the table

您可以将 2,147,483,648 (2^31) 添加/减去常规 int 吗?(在进来的路上减去,然后加上出来)我知道这听起来很傻,但是如果你声明一个自定义数据类型来做这个,它是整数算术并且非常快......它只是不能直接从表中读取

回答by Gus Leo

You can use bigint with checked the constraint, but datatype will still in 8 byte :(

您可以使用 bigint 并检查约束,但数据类型仍为 8 字节 :(

回答by Redha Student

I used BINT(11) instead of INT(11), and it acts as UNSIGNED INT(11)

我使用 BINT(11) 而不是 INT(11),它充当 UNSIGNED INT(11)