1. Home
  2. Docs
  3. Oracle to PostgreSQL Migration
  4. Database Migration Basics
  5. Data types

Data types

There are many incompatibilities in Oracle and PostgreSQL. The most common difference many people might notice is – PostgreSQL has rich set of data types. As of PostgreSQL version 10 an empty PostgreSQL database will expose the staggering number of 92 data types. Of course not all of them are useful and many of them are purely for internal purposes.

Before you begin with code migration from Oracle, it is utmost important to understand the data types in PostgreSQL. Some of the important Data type conversion between Oracle and PostgreSQL is as follow.

Data type Mapping

OraclePostgreSQL
INT, INTEGERINT, INTEGER
NUMBER(p); p < 5SMALLINT
NUMBER(p); p < 9INTEGER
NUMBER(p); p < 19BIGINT
NUMBER(p); p >= 19NUMERIC
NUMBERDepends on what type of data is stored. Decide wisely between SMALLINT / INTEGER / BIGINT / DOUBLE PRECISION / NUMERIC
NUMBER(p, s)DECIMAL(p,s) or NUMERIC(p, s) – Choose only in case of decimal data. Choose INTEGER/BIGINT instead to stored integer data values.
VARCHAR2(n)VARCHAR(n) or CHARACTER VARYING(n)
DATEDepends – DATE or TIMESTAMP
TIMESTAMPTIMESTAMP
LONGTEXT
CHAR(n)CHAR(n)
CLOBTEXT
BLOBBYTEA
RAW(n)BYTEA
XMLTYPEXML
Was this article helpful to you? Yes No

How can we help?