问题描述
我已经看到了一些例子,其中小数
在NHibernate的项目用于映射到Oracle整数列。现在,我使用 INT
和长
在我的计划。
什么是小数
超过 INT
/ 长$ C $的优势C>?是否有更好的表现?
That's probably because .NET decimal
and Oracle NUMBER
maps a bit better than long
and NUMBER
and it also gives you more flexibility. If you at a later stage add a scale in the Oracle column then you wouldn't have to change datatype if you already used decimal
.
decimal
is certainly slower than int
and long
since the later two are supported in hardware. That said, you have to crunch some serious amount of data for it to make any difference. I still think that you should use long
if that that's what you're dealing with and then you should also let the table column definitions represent that. NUMBER(18,0)
for long
and so on.
The reason decimal
maps a little better is that long
is 64 bits and decimal
is (kind of) 128 bits.
.NET
Oracle
NUMBER
defaults to 38 significant digits and scale 0 (integer).
Microsoft is aware of the problem and notes
Come to think of it you actually need BigInteger
to be able to represent the same number of significant digits as to what NUMBER
defaults to. I've never seen anyone do that and I would suppose it's a very rare need. Also BigInteger
still wouldn't cut it since NUMBER
can be of positive and negative infinity.
这篇关于其中.NET数据类型是最适合在映射的NHibernate的数量的Oracle数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!