PolarDB for PostgreSQL (Compatible with Oracle) supports a broad set of data types spanning numeric, string, date/time, JSON, XML, geometric, network, and full-text search categories. Many Oracle type names are accepted directly, so existing DDL often requires little or no change.
Common data types
Different type names can share the same storage structure and processing logic. PolarDB groups these under a Display type — the canonical name used internally. Understanding this grouping helps you recognize which Oracle type names map to which PostgreSQL-native types.
| Type name | Display type | Description |
|---|---|---|
boolean, bool | boolean | Logical Boolean (true/false) |
serial2 | smallint | Auto-incrementing 2-byte integer |
serial, serial4 | integer | Auto-incrementing 4-byte integer |
bigserial | bigint | Auto-incrementing 8-byte integer |
smallint, int2 | int2 | Signed 2-byte integer; range −32,768 to 32,767 |
integer, binary_integer, int, int4 | integer | Signed 4-byte integer; range −2,147,483,648 to 2,147,483,647 |
bigint, int8 | int8 | Signed 8-byte integer; range −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
binary_float, float4, real | real | Single-precision floating-point; 4 bytes; ~6 decimal digits of precision |
binary_double, float8, double precision | double precision | Double-precision floating-point; 8 bytes; ~15 decimal digits of precision |
decimal [ (p,s) ], number [ (p,s) ], numeric [ (p,s) ] | numeric [ (p,s) ] | Exact numeric with user-specified precision and scale |
raw, blob, bytea | bytea | Binary data (byte array) |
bit [ (n) ] | bit [ (n) ] | Fixed-length bit string |
bit varying [ (n) ], varbit [ (n) ] | bit varying [ (n) ] | Variable-length bit string |
clob, string, long, nclob, text | text | Variable-length string with no length limit |
character [ (n) ], nchar [ (n) ], char [ (n) ] | character [ (n) ] | Fixed-length string padded with spaces to length n |
character varying [ (n) ], varchar2 [ (n) ], nvarchar2 [ (n) ], varchar [ (n) ] | character varying [ (n) ] | Variable-length string; stores only the actual content |
date | date | Date and time (year, month, day, hour, minute, second) |
time [ (p) ] [ without time zone ] | time [ (p) ] [ without time zone ] | Time of day without time zone |
time [ (p) ] with time zone | time [ (p) ] with time zone | Time of day with time zone |
timestamp [ (p) ] [ without time zone ] | timestamp [ (p) ] [ without time zone ] | Date and time without time zone |
timestamp [ (p) ] with time zone, timestamp [ (p) ] with local time zone | timestamp [ (p) ] with time zone, timestamp [ (p) ] with local time zone | Date and time with time zone |
interval [ fields ] [ (p) ] | interval [ fields ] [ (p) ] | Time span |
json | json | Textual JSON data |
jsonb | jsonb | Binary JSON data (pre-parsed); supports indexing |
jsonpath | jsonpath | Path expression for querying JSON data |
json_element_t | json_element_t | JSON base class compatible with Oracle syntax |
json_array_t | json_array_t | JSON array compatible with Oracle syntax |
json_object_t | json_object_t | JSON object compatible with Oracle syntax |
json_key_list | json_key_list | Variable-length array of type VARCHAR2 for storing JSON object key names |
json_nkey_list | json_nkey_list | Variable-length array of type NVARCHAR2 for storing JSON object key names |
box | box | Rectangle on a plane |
cidr | cidr | IPv4 or IPv6 network address |
circle | circle | Circle on a plane |
rowid | rowid | Row identifier type |
urowid | urowid | Universal row identifier type |
xml | xml | XML data |
xmltype | xmltype | XML data compatible with Oracle syntax |
xmlsequencetype | xmlsequencetype | Variable-length array of xmltype; return value of the xmlsequence function |
inet | inet | IPv4 or IPv6 host address |
line | line | Infinite line on a plane |
lseg | lseg | Line segment on a plane |
macaddr | macaddr | MAC (Media Access Control) address |
macaddr8 | macaddr8 | MAC address in EUI-64 format |
money | money | Monetary amount |
path | path | Geometric path on a plane |
pg_lsn | pg_lsn | PostgreSQL log sequence number |
pg_snapshot | pg_snapshot | Transaction ID snapshot |
txid_snapshot | txid_snapshot | Transaction ID snapshot — deprecated; use pg_snapshot instead |
point | point | Geometric point on a plane |
polygon | polygon | Closed geometric path on a plane |
tsquery | tsquery | Full-text search query type |
tsvector | tsvector | Full-text search document type |
uuid | uuid | Universally Unique Identifier |
Oracle-to-PolarDB type mapping
Oracle type names that appear in the Type name column above are accepted directly. The following DDL example shows how common Oracle column types map when used in PolarDB.
-- Oracle DDL (source)
CREATE TABLE sales (
id NUMBER(10),
amount BINARY_DOUBLE,
payload BLOB,
description CLOB,
created_at DATE,
label NVARCHAR2(100),
raw_data RAW(200),
doc XMLTYPE
);
-- Equivalent PolarDB DDL
-- Oracle aliases resolve to the display types shown in the table above
CREATE TABLE sales (
id numeric(10), -- NUMBER -> numeric
amount double precision, -- BINARY_DOUBLE -> double precision
payload bytea, -- BLOB -> bytea
description text, -- CLOB -> text
created_at date, -- DATE -> date (includes time component)
label character varying(100), -- NVARCHAR2 -> character varying
raw_data bytea, -- RAW -> bytea
doc xmltype -- XMLTYPE -> xmltype (Oracle-compatible)
);The Oracle DATE type stores date and time down to the second. In PolarDB this maps to the date display type, which retains the same behavior. If you need sub-second precision, use timestamp.
Selection guide
json vs jsonb
Use jsonb for most workloads. It stores data in an optimized binary format, supports indexing, and delivers far better query performance than json. The json type stores data as plain text, which allows for fast insertions, making it suitable for audit logging or cases where exact text fidelity matters.
Numeric precision
When using numeric or decimal, always specify precision and scale to control storage size and accuracy. Example: numeric(10, 2).
String types
character(n) (and its alias char(n)) pads values with spaces to length n, which can cause unexpected comparison behavior. Prefer varchar or text unless you have a specific fixed-length requirement.
Integer types
Choose the smallest type that fits your data range:
smallint— −32,768 to 32,767; use for compact lookup tables or flagsinteger— −2,147,483,648 to 2,147,483,647; the default choice for most integer columnsbigint— up to ~9.2 × 10¹⁸; use for counters, user IDs, or any column that may exceed two billion rows
For auto-incrementing primary keys, use serial (integer-sized) or bigserial (bigint-sized).
FAQ
What is the difference between varchar(n) and text, and which should I use?
There is no performance difference between varchar(n) and text in PolarDB for PostgreSQL (Compatible with Oracle). The only difference is that varchar(n) rejects values longer than n characters at insert time, while text has no length limit. If your schema does not need a hard length constraint, use text — it simplifies schema evolution and avoids silent truncation surprises.
How do I choose the right integer type?
Start with integer. It covers the vast majority of use cases (up to about ±2.1 billion). Switch to bigint when you expect values to exceed that range, such as global counters or row IDs in high-volume tables. Use smallint only when storage compactness is critical and the range −32,768 to 32,767 is sufficient.
For auto-incrementing IDs, use serial (integer range) or bigserial (bigint range).