开发者

Oracle: Binary integer type

开发者 https://www.devze.com 2023-03-27 07:47 出处:网络
I want to basically have an \"id\" type in Oracle. An example which would satisfy my needs wou开发者_StackOverflow社区ld be a 32/64 bit integer where NULL is represented as -INT_MIN.

I want to basically have an "id" type in Oracle.

An example which would satisfy my needs wou开发者_StackOverflow社区ld be a 32/64 bit integer where NULL is represented as -INT_MIN.

I don't need this to be variable length (like NUMBER). I considered using RAW but I don't believe there is an implicit conversion from RAW to integers.

It seems an option is BINARY_DOUBLE. Is this the best approach?


Use NUMBER(10, 0), which is equivalent to NUMBER(10). BINARY_DOUBLE is a floating-point representation, not an integer. I figure, don't second-guess the database, unless you have a specific reason to do so. You may be talking yourself out of behind the scenes data optimizations that the CBO can do (though I don't know if there are any). You say you want an integer, so use an integer.

And why would you want to represent NULL as -INT_MIN? Represent NULL as NULL.


Not sure of your entire requirement, but yes it appears you're correct:

http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i16209

0

精彩评论

暂无评论...
验证码 换一张
取 消