Updated November, 23 2023

Type Mapping#

We cover a few notable differences in translation:

Oracle DB

PostgreSQL

VARCHAR2

VARCHAR

NVARCHAR2

VARCHAR

NCHAR

CHAR

NUMBER(n, m)

NUMERIC(n,m)

NUMBER( n<=4)

SMALLINT

NUMBER( n<=9)

INT

NUMBER( n<=18)

BIGINT

NUMBER( n>18)

NUMERIC(n)

BINARY_INTEGER

INTEGER

BINARY_FLOAT

FLOAT

DATE

TIMESTAMP(0)

TIMESTAMP WITH LOCAL TIME ZONE

TIMESTAMPTZ

CLOB

TEXT

LONG

TEXT

BLOB

BYTEA

RAW(n)

BYTEA

LONG RAW

BYTEA


Details:

1. Oracle char datatypes have BYTE and CHAR notation for sizing. Where BYTE corresponds to length in bytes and CHAR to length in characters. Postgre has only char length. We ignore BYTE and CHAR notation. There will be no error for 1 to 1 Byte to Char translation. Just the length on Postgres will be bigger than it’s needed. Default values depend on the session variable NLS_LENGTH_SEMANTICS.

 1--Oracle
 2DECLARE
 3  var1 VARCHAR2(1 char) := 'й';
 4  var2 VARCHAR2(1 char) := 'q';
 5  var3 VARCHAR2(1 byte) := 'й';  --error MultyByte char
 6  var4 VARCHAR2(1 byte) := 'q';
 7  var5 VARCHAR2(2 byte) := 'й';
 8BEGIN
 9  NULL;
10END;

2. BLOB, RAW(n), LONG RAW maps to BYTEA or to a Large object if stored data larger 1 GB limit. We map to BYTEA by default.