Data Type Mapping Between Oracle and MySQL

By Hassan Shareef, Database Administrator — 16 years of experience


When converting data from Oracle to MySQL, we need to map Oracle column data types to their equivalent in MySQL. Most datatypes map directly since their behavior is the same in both databases, but for some — like NUMBER, BLOB, and CLOB — we need to choose the nearest equivalent.

When migrating data between Oracle and MySQL, it's essential to understand how Oracle data types correspond to MySQL data types to prevent data loss, truncation, or compatibility issues.

Planning to migrate data between an Oracle database and MySQL? Download and use Data Loader and achieve migration in just a few clicks.

Free Download Now

1. Numeric Data Types

Numeric data types store numerical values, including integers and floating-point numbers.

Oracle Data TypeMySQL EquivalentRemarks
NUMBER(p,s)DECIMAL(p,s) or NUMERIC(p,s)Same precision and scale handling in both databases.
NUMBER(p)DECIMAL(p,0) or BIGINTIf no scale is given, it's treated as an integer.
NUMBER (without p,s)DOUBLE or DECIMALOracle's flexible NUMBER has no direct equivalent — use DECIMAL for exact values, DOUBLE for floating points.
BINARY_FLOATFLOATSingle-precision floating point.
BINARY_DOUBLEDOUBLEDouble-precision floating point.
FLOAT(p)FLOAT(p) or DOUBLEOracle FLOAT(p) is an alias for NUMBER(p,-127). MySQL uses FLOAT for precision ≤24, DOUBLE for >24.
INTEGER / INTINTEquivalent in both databases.
SMALLINTSMALLINTEquivalent in both databases.
BIGINTBIGINTEquivalent in both databases.
Considerations

2. String Data Types

String data types store character-based data.

Oracle Data TypeMySQL EquivalentRemarks
CHAR(n)CHAR(n)Fixed-length character string.
VARCHAR2(n)VARCHAR(n)Variable-length character string.
NCHAR(n)CHAR(n) CHARACTER SET utf8mb4National character type for Unicode support.
NVARCHAR2(n)VARCHAR(n) CHARACTER SET utf8mb4National character type for Unicode support.
CLOBTEXT or LONGTEXTOracle's CLOB is for large text storage; MySQL uses TEXT types.
NCLOBTEXT CHARACTER SET utf8mb4Unicode equivalent of CLOB.
LONGTEXT or LONGTEXTLONG is deprecated in Oracle; use TEXT in MySQL.
RAW(n)VARBINARY(n)Binary data storage.
LONG RAWBLOBLarge binary object storage.
Considerations

3. Date and Time Data Types

Oracle and MySQL store date and time data differently.

Oracle Data TypeMySQL EquivalentRemarks
DATEDATETIMEOracle's DATE includes time; MySQL's DATE does not. Use DATETIME for full equivalence.
TIMESTAMPTIMESTAMPStores date and time with fractional seconds.
TIMESTAMP WITH TIME ZONETIMESTAMP + CONVERT_TZ()MySQL doesn't natively support time zones in timestamps.
TIMESTAMP WITH LOCAL TIME ZONETIMESTAMPTime zone is stored per session in Oracle but not in MySQL.
Considerations

4. LOB (Large Object) Data Types

LOB types are used for large data storage.

Oracle Data TypeMySQL EquivalentRemarks
BLOBBLOBEquivalent.
CLOBTEXTEquivalent for text-based large storage.
NCLOBTEXT CHARACTER SET utf8mb4Unicode large text storage.
Considerations

5. Miscellaneous Data Types

Oracle Data TypeMySQL EquivalentRemarks
ROWIDNo direct equivalentUnique row identifier in Oracle.
UROWIDNo direct equivalentUniversal row identifier.
XMLTYPETEXT or JSONOracle's XML storage can be handled using TEXT or JSON in MySQL.
Considerations

6. Handling Auto-Increment Columns

In Oracle, auto-increment behavior is handled using sequences, whereas MySQL provides AUTO_INCREMENT.

Oracle
CREATE SEQUENCE my_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE my_table (
  id NUMBER PRIMARY KEY DEFAULT my_seq.NEXTVAL
);
MySQL
CREATE TABLE my_table (
  id INT AUTO_INCREMENT PRIMARY KEY
);
Migration Tip

7. Summary of Key Differences

  1. Number Handling: Oracle's NUMBER type is highly flexible, whereas MySQL requires explicit DECIMAL, INT, or DOUBLE.
  2. String Storage: Oracle differentiates between VARCHAR2 and VARCHAR, while MySQL does not.
  3. Date Handling: Oracle's DATE includes time, but MySQL requires DATETIME or TIMESTAMP.
  4. LOBs: Oracle's CLOB maps to MySQL's TEXT, but indexing and performance differ.
  5. Auto-Increment: MySQL provides AUTO_INCREMENT, whereas Oracle requires sequences.

When migrating data between Oracle and MySQL, careful data type mapping is crucial to avoid truncation, performance degradation, or compatibility issues. Use tools like Data Loader, Oracle SQL Developer, MySQL Workbench, or custom scripts to automate and validate conversions.