eastwater
eastwater

Reputation: 5620

which oracle datatype is mapped to BIGINT?

SQL> CREATE TABLE Product (id NUMBER(19,0) NOT NULL, name VARCHAR2(10 CHAR) NOT NULL);

Table created.

SQL> desc Product;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                        NOT NULL NUMBER(19)
 NAME                                      NOT NULL VARCHAR2(10 CHAR)

type NUMBER(19,0) becomes NUMBER(19).

From JDBC, the id type NUMBER(19) is mapped to java.sql.Types.DECIMAL, not java.sql.Types.BIGINT. What is the oracle database type mapped to jdbc BIGINT?

Upvotes: 5

Views: 28773

Answers (1)

Paul Maxwell
Paul Maxwell

Reputation: 35603

8.3.7 BIGINT

The JDBC type BIGINT represents a 64-bit signed integer value between -9223372036854775808 and 9223372036854775807.

The corresponding SQL type BIGINT is a nonstandard extension to SQL. In practice the SQL BIGINT type is not yet currently implemented by any of the major databases, and we recommend that its use be avoided in code that is intended to be portable.

The recommended Java mapping for the BIGINT type is as a Java long. https://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/mapping.html

However not entirely sure that statement about no RDBMS having implemented BIGINT that way, MS SQL Server documentation states:

Data type   Range   Storage
bigint  -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)    8 Bytes

https://learn.microsoft.com/en-us/sql/t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql

Notwithstanding the JDBC mapping is to LONG

Upvotes: 2

Related Questions