Loading...

We've detected that your browser language is Chinese. Would you like to visit our Chinese website? [ Dismiss ]
By: Emma

Migrating from MySQL to Oracle involves more than moving table data. Differences in SQL syntax, data types, constraints, and stored procedures can cause conversion errors or break application behavior if not addressed beforehand.

The right migration method and proper validation at each stage help reduce downtime and ensure the Oracle database works as expected.

how to migrate mysql to oracle database with 4 methods

Before You Start: MySQL-to-Oracle Migration Checklist

Before migrating, review the source database structure, Oracle compatibility, and application dependencies. Addressing these issues early helps prevent conversion errors and unexpected application behavior.

Migration checklist

  • Verify versions and connectivity. Check the MySQL source version, Oracle target version, database size, network access, and application dependencies. Confirm that your migration tools and drivers support both versions.
  • Audit database objects. Inventory tables, columns, indexes, constraints, views, triggers, stored procedures, and functions. Identify objects that require manual conversion due to differences in how MySQL and Oracle handle them.
  • Review data type compatibility. Map MySQL data types to suitable Oracle equivalents before creating the target schema. Pay attention to numeric precision, string lengths, date and time values, and large objects.
  • Check SQL and application compatibility. Review AUTO_INCREMENT, LIMIT, empty-string handling, and MySQL-specific functions, as these can affect query results and application logic after migration.
  • Back up the source and prepare the target. Create and verify a recoverable MySQL backup. Prepare the Oracle schema, user permissions, tablespaces, and storage before starting.
  • Define validation and rollback criteria. Decide how to verify row counts, check database objects, and test application transactions. Establish a rollback plan before moving production data.

MySQL-to-Oracle data type mapping

MySQL and Oracle use different data type definitions. The table below provides common mappings to review when preparing the target schema. The appropriate Oracle type depends on the source column definition, actual values, and application requirements.

MySQL Potential Oracle equivalent Migration considerations
TINYINT(1) / Boolean-like values NUMBER(1) Check actual values and Boolean handling in the application.
AUTO_INCREMENT Identity column or sequence Preserve existing key values; choose type based on Oracle version.
VARCHAR(n) VARCHAR2(n) Review lengths, character semantics, and character sets.
TEXT / LONGTEXT CLOB Check size limits and how the application accesses the data.
DATETIME DATE or TIMESTAMP Use TIMESTAMP if fractional-second precision is required.
DECIMAL(p,s) NUMBER(p,s) Verify precision, scale, and rounding behavior.
BLOB BLOB Validate transfer integrity and file sizes.
Note: These are potential mappings, not automatic conversions. Review the official documentation for your MySQL and Oracle versions before finalizing the schema.

How to Migrate MySQL to Oracle Database: 4 Methods

The right migration method depends on your database size, schema complexity, and whether you need to convert database objects alongside table data. The following four methods cover GUI-based migration, file-based data transfer, SQL script conversion, and ODBC-based tools.

Method 1: Migrate with Oracle SQL Developer

Oracle SQL Developer includes a migration workbench for moving third-party databases to Oracle. Before starting, confirm that your SQL Developer version supports your MySQL source version.

Based on available Oracle documentation, the migration workbench supports MySQL 3.x, 4.x, and 5.x. Support for MySQL 8.0 is not confirmed — check the Oracle documentation for your SQL Developer version before proceeding.

Tip: The steps below provide a process overview. For version-specific menu paths and UI details, refer to the Oracle SQL Developer migration documentation for your release.

Step 1. Prepare the migration environment

  • Install a compatible version of SQL Developer and review its migration requirements.
  • Configure the MySQL JDBC driver if your connection workflow requires it, and test connectivity to the source database.
  • Prepare the Oracle target schema and migration repository. Confirm that the migration account has the necessary privileges.

Step 2. Connect to the MySQL source and Oracle target

  • Configure the MySQL connection and verify access to the database objects and table data.
  • Configure the Oracle connection and confirm that the account can create the required tables, indexes, and constraints.

Step 3. Capture and convert the source schema

  • Create a migration project and capture the MySQL database metadata.
  • Review the proposed Oracle data type mappings, table definitions, identifiers, and constraints.
  • Resolve conversion warnings and manually adjust incompatible definitions, including MySQL-specific syntax.
  • Generate and review the target DDL scripts before execution.

Step 4. Execute the target DDL

  • Execute the reviewed DDL against the Oracle target.
  • Check for failed statements, invalid object definitions, and naming conflicts.
  • Verify that all expected tables, indexes, and constraints exist before transferring data.

Step 5. Transfer data and validate

  • Use the data migration workflow in SQL Developer to transfer the source table data.
  • Review migration logs and check for rejected rows and data type conversion failures.
  • Compare source and target row counts and inspect critical records, including dates, numeric values, and large objects.
  • Test application queries and transactions against Oracle before switching production workloads.

Method 2: Export MySQL Data and Load It into Oracle

Exporting data to CSV and loading it into Oracle is a practical option for moving selected tables when a full schema migration is unnecessary. This method covers data transfer only — create and verify the target schema separately before loading.

Step 1. Export data from MySQL

Use SELECT ... INTO OUTFILE or a suitable export utility to generate CSV files:

bash
SELECT id, name, email
INTO OUTFILE '/var/lib/mysql-files/customers.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM customers;

The MySQL server needs write permission to the specified directory. If INTO OUTFILE is not available, use a client-side export tool instead.

Step 2. Create the Oracle target tables

Create the destination tables before loading. Map MySQL column types to Oracle equivalents and review column lengths, numeric precision, and constraints. For example, VARCHAR(100) maps to VARCHAR2(100), and DATETIME may require DATE or TIMESTAMP depending on precision requirements.

Step 3. Load the CSV files into Oracle

Use SQL*Loader to load the exported files. Create a control file that defines the input fields and target columns:

bash
LOAD DATA
INFILE 'customers.csv'
INTO TABLE customers
APPEND
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(id, name, email)

Then run SQL*Loader:

bash
sqlldr userid=USER/PASSWORD@ORACLE_SERVICE \
  control=customers.ctl \
  log=customers.log \
  bad=customers.bad

Use a secure authentication method in production — avoid exposing credentials in command history. Fields with embedded newlines, complex date formats, or special characters may need additional control file settings.

Step 4. Review errors and validate

  • Check the log file for loaded, rejected, and skipped records.
  • Inspect the .bad file and fix any formatting or conversion issues.
  • Compare source and target row counts and verify NULL values, dates, numeric precision, and text encoding.
  • Run application queries against the loaded tables to confirm the data behaves as expected.

For databases with strict downtime requirements, plan for incremental changes and final synchronization separately.

Method 3: Convert SQL Scripts with SQLines

SQLines SQL Converter converts DDL statements, queries, stored procedures, functions, and triggers between supported database platforms. It is useful for bulk script conversion, but review all output carefully — automated conversion does not guarantee equivalent behavior in Oracle.

Step 1. Prepare the source scripts

  • Export the MySQL schema and database objects into SQL scripts.
  • Keep an unchanged copy of the originals for comparison.

Step 2. Run the conversion

  • Download SQLines SQL Converter from the official SQLines website and review the supported features for your version.
  • Select MySQL as the source and Oracle as the target, then process the relevant SQL files.

Step 3. Review and correct the output

Inspect the converted scripts for syntax and behavior differences. Common issues include:

  • Auto-increment: Convert AUTO_INCREMENT to an Oracle identity column or sequence.
  • Pagination: Replace LIMIT with an Oracle-compatible equivalent.
  • Empty strings: Oracle treats zero-length strings as NULL — review any logic that depends on this distinction.
  • Stored routines: Procedural logic, exception handling, and built-in functions may need substantial manual rewriting.

Test the corrected scripts in a non-production Oracle environment before proceeding.

Step 4. Transfer data separately

Script conversion does not migrate table data. Use SQL*Loader or another transfer method to move the records, then verify row counts, constraints, indexes, and application queries.

Best for: Teams converting large volumes of SQL scripts in bulk, particularly when a command-line workflow is preferred over a GUI.

Method 4: Migrate Data with an ODBC-Based Tool

ODBC-based migration tools connect to MySQL and Oracle through database drivers and offer a configurable interface to map and transfer data. This approach suits teams that prefer a graphical workflow over command-line methods.

Step 1. Choose a compatible tool

  • Select a tool that supports both MySQL and Oracle as source and target.
  • Confirm it covers the operations you need: data transfer, column mapping, and error reporting. Most ODBC-based tools transfer data only and do not convert stored procedures or other database objects.
  • Check compatibility with your database versions, operating system, and authentication requirements.

Step 2. Configure drivers and connections

  • Install a compatible MySQL ODBC driver and configure the connection settings.
  • Install the Oracle connectivity components required by your tool — either an Oracle ODBC driver or a native Oracle client.
  • Configure both connections, including hostnames, ports, service names, and credentials.
  • Test connectivity and confirm the migration account has sufficient read and write privileges.

Step 3. Map source tables and columns

  • Select the MySQL tables and columns to migrate.
  • Map each source column to the appropriate Oracle target column, adjusting data types, lengths, and precision as needed.
  • Configure transformations for values that require conversion, such as dates, Boolean-like values, or character encodings.
  • If the tool does not handle indexes, constraints, or keys, prepare separate Oracle DDL scripts for those objects.

Step 4. Run a test migration

  • Start with a small dataset or a representative set of tables.
  • Review the execution logs for rejected records, truncation warnings, and conversion errors.
  • Compare row counts and inspect records with NULL values, special characters, or binary data.
  • Fix mapping and configuration issues before migrating the remaining tables.

Step 5. Migrate remaining data and validate

  • Migrate in batches to control resource usage and simplify troubleshooting.
  • Validate row counts, key relationships, numeric values, and dates.
  • Test application queries and transactions against Oracle before completing the cutover.

Best for: Teams that need GUI-based column mapping without building a custom migration pipeline. Note that ODBC connectivity alone does not make MySQL SQL or stored procedures compatible with Oracle — confirm the tool’s schema conversion capabilities separately.

Simplify MySQL-to-Oracle Migration with i2Migration

The methods above work well for straightforward transfers, but production databases often require stricter controls: minimal downtime, transactional consistency, and keeping the source system running throughout.

i2Migration is a unified migration platform built for these scenarios. For database migration, it uses redo log parsing to achieve semantic-level, asynchronous replication, maintaining transactional consistency even under high concurrency. The entire migration process can run on a live production system without interruption.

Key capabilities relevant to MySQL-to-Oracle migrations:

  • Near real-time sync: Log-based replication keeps the source and target in sync during migration, reducing the cutover window significantly.
  • Transactional consistency: Checkpoint-based and rollback-validated sync ensures data integrity throughout the process.
  • Broad database support: Compatible with Oracle, MySQL, SQL Server, PostgreSQL, DB2, and other mainstream relational databases.
  • Built-in validation: End-to-end dataset validation with automatic correction, plus support for rollback and point-in-time recovery if issues arise.
  • Secure transfer: AES/SM4 encryption, bandwidth control, compression, and resume-from-breakpoint for reliable transfers across long distances.
FREE Trial for 60-Day

Common MySQL-to-Oracle Migration Issues and How to Fix Them

Even when the data transfer completes, differences between MySQL and Oracle can cause SQL errors, missing records, or unexpected application behavior. Check the following issues during testing and validation before switching production workloads to Oracle.

SQL syntax and stored procedure incompatibilities

MySQL and Oracle use different SQL dialects, and some statements that work in MySQL are invalid or behave differently in Oracle. For example, MySQL uses LIMIT for pagination, while Oracle supports OFFSET ... FETCH in recent versions. Stored procedures may also require changes to control flow, built-in functions, exception handling, and variable declarations.

How to fix it: Rewrite unsupported syntax in converted SQL scripts. Compile stored procedures, functions, and triggers in a test environment and verify their behavior with representative inputs. Successful compilation does not guarantee equivalent results.

Data type conversion and truncation errors

Data type mismatches can cause failed inserts, lost precision, or truncated values. Mapping a MySQL DATETIME column to Oracle DATE may lose fractional seconds, and an undersized VARCHAR2 column may reject longer strings. Numeric columns can also lose precision if the target definition does not match the source values.

How to fix it: Review the data type mapping before creating target tables. Check actual source values, maximum string lengths, and numeric precision. After loading, compare representative values and investigate any rejected rows or conversion warnings.

Empty strings converted to NULL

Oracle treats zero-length character strings as NULL, while MySQL distinguishes an empty string ('') from NULL. This difference can affect filters, uniqueness checks, and application logic that relies on telling the two apart.

How to fix it: Identify columns where empty strings carry business meaning. Update application logic and SQL conditions to account for Oracle’s behavior, and define an explicit replacement value if the distinction needs to be preserved. Test affected queries and constraints before cutover.

Connection and authentication errors

Connection failures can occur when the migration tool uses an incompatible driver, the service name is incorrect, network access is blocked, or the migration account lacks the required privileges.

How to fix it: Test source and target connections independently before starting the transfer. Verify hostnames, ports, service names, driver versions, and account permissions. Check the driver and database logs to identify the cause rather than retrying the migration blind.

Missing rows and data consistency issues

A migration can complete with skipped or rejected records even when the target tables exist. Common causes include duplicate keys, incompatible constraints, interrupted transfers, and incorrect CSV delimiters or character encoding. Comparing only total row counts can also miss differences in individual records.

How to fix it: Compare row counts per table, inspect rejected-row logs, and verify critical records by primary key. Check referential integrity and representative text and numeric values. If the source database changes during migration, use a planned synchronization and cutover process to capture those changes.

Conclusion

Migrating from MySQL to Oracle requires careful preparation — reviewing data types, auditing database objects, and choosing a method that fits your schema complexity and downtime tolerance. Oracle SQL Developer suits teams already in the Oracle ecosystem; CSV export and SQL*Loader work for selective table transfers; SQLines helps with bulk script conversion; and ODBC-based tools offer a GUI-driven alternative for column mapping.

Whichever method you use, validate the results at each stage before switching production workloads. Row count checks and spot inspections of critical records catch most issues before they affect applications.

For production databases where downtime and data consistency are a priority, i2Migration provides a non-disruptive migration path with log-based replication and built-in validation. Info2soft offers a range of data protection and migration solutions for complex enterprise environments.

Emma is the bridge between complex engineering and the people who need it. As a content creator at Info2soft, she spends her days translating "tech-speak" into clear, actionable stories about data resilience. She’s not just documenting software; she's uncovering how data replication and recovery actually change the way businesses run.

More Related Articles

Ready to Enhance Business Data Security?

· Enterprise & Mid-market Customers Worldwide

· Support team available to assist you throughout your trial

· Start a 60-day free trial or view demo to see how Info2Soft protects enterprise data.

Please fill out the form and submit it, our customer service representative will contact you soon.
By submitting this form, I confirm that I have read and agree to the Privacy Notice.
{{ isSubmitting ? 'Submitting...' : 'Submit' }}