相当于 C# BigInteger 的 SQL [英] SQL equivalent of C# BigInteger
问题描述
所以,我一直在使用 .NET 4 中引入的新 BigInteger
类来存储难以置信的大数字.
So, I've been using the new BigInteger
class introduced in .NET 4 to store incredibly large numbers.
现在,我开始考虑将这些数字保存到数据库 (SQL Server).我的问题是,这甚至可能吗?据我所知和我研究过的,SQL 数据类型不包含与 BigInteger
的行为相对应的属性(理论上没有最小值或最大值).
Now, I've started thinking about saving these numbers to the database (SQL Server). My question is, is this even possible? As far as I know and what I've researched, the SQL data types do not contain a property that corresponds to the behaviour of BigInteger
(theoretically no min or max).
我见过的最接近的是 bigint
,但它的最小值是 -2^63 (-9,223,372,036,854,775,808)
和 <2^63-1 (9,223,372,036,854,775,807)
的强>最大值.
The closest I've seen is bigint
, but that has a minimum of -2^63 (-9,223,372,036,854,775,808)
and a maximum of 2^63-1 (9,223,372,036,854,775,807)
.
推荐答案
如果您的 SQL 服务器的 DECIMAL
类型不支持您需要的精度,您只能选择将数字存储为字符串或二进制,即在 VARCHAR中code>、
TEXT
或 VARBINARY
字段.
If your SQL server's DECIMAL
type does not support the precision you need you'll only have the option to store the number as a string or a binary, i.e. in a VARCHAR
, TEXT
or VARBINARY
field.
这篇关于相当于 C# BigInteger 的 SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!