views:

194

answers:

4

What type in Oracle (10 Express Edition) would be the "same" as a Java int?

+3  A: 

I'd say number(10,0).

Pascal Thivent
+9  A: 

Java's int has a range of -2,147,483,648 to 2,147,483,647 - so Number(10,0) is as close as you're going to get...

Martin Milan
And, if appropriate, you can add a check constraint to the column, `check (column_name between -2147483648 and 2147483647)` to make sure the data stored does not fall outside of the range that the application can handle.
Shannon Severance
shouldn't this be NUMBER(9,0)? With NUMBER(10,0) you could have a value (e.g. 9,999,999,999) that would exceed the range of a Java int.
Aaron F.
No - then you wouldn't be covering the whole of the int type's range.
Martin Milan
Shannon Severance's point above will handle it.
Martin Milan
A: 

try NUMBER . In Oracle we use Number for Integer

eoracleapps
A: 

I suggest using BINARY_INTEGER. BINARY_INTEGER is declared in SYS.STANDARD with a range of -2147483647 to 2147483647.

Share and enjoy.

Bob Jarvis
Except, of course, that it can't be used in a table. Not thinking clearly - my bad.
Bob Jarvis