Data migration plays a vital role in various business scenarios. When your company moves its services from on-premises to the cloud, data migration steps in to transfer data from the old location to the new one. Another common practice might be to replace or upgrade servers or storage devices. In such cases, data migration ensures smooth and efficient transfer of data, minimizing downtime and disruption. Additionally, data migration can help maintain database integrity and consistency by ensuring that important information remains accurate and accessible in the new environment.
In this article, we will explore how to migrate data from Oracle to MySQL tables using dbForge Studio for MySQL and Devart ODBC driver for Oracle .
Why migrate from an Oracle database to a MySQL database?
You may need to migrate data from Oracle to MySQL database for any reason, such as:
- MySQL is more cost effective compared to Oracle. Because MySQL is an open source database, there are no associated licensing costs.
- MySQL is simple yet flexible due to its easy setup process and user-friendly interface. The syntax and commands in MySQL are generally easier to learn and understand than Oracle's more complex and feature-rich PL/SQL language.
- Due to its high performance and scalability, MySQL can efficiently process large amounts of data while maintaining optimal database performance.
- MySQL benefits from an open source community that provides a wealth of troubleshooting and development support, resources, and documentation. The community frequently releases updates and improvements to the MySQL database, ensuring it remains reliable and up-to-date.
- Compatible with multiple platforms and operating systems, MySQL can be easily integrated with various programming languages, frameworks and tools to make data migration easier.
prerequisites
Database migration includes migrating schema, tables, and data. To do this, we will download and use the following tools:
- dbForge Edge
is a general suite of four database IDEs, each allowing database development, administration and administration tasks to be performed on different database systems, including Microsoft SQL Server, MySQL, MariaDB, Oracle, PostgreSQL and Amazon Redshift. The data import feature available in all Studios allows users to quickly and easily import data from multiple sources, including ODBC drivers. - Devart ODBC Driver for Oracle
is a reliable and simple tool for accessing Oracle databases through ODBC compliant tools on 32-bit and 64-bit Windows, macOS and Linux.
Advantages of Using ODBC
Before delving into data migration, let's take a look at the benefits that developers and organizations can gain by using the Devart ODBC driver:
- Supports a variety of databases, including popular databases such as Oracle, MySQL, PostgreSQL, SQL Server, and SQLite.
- Since CPU cycles and RAM usage are minimized, fewer system resources are used while processing the same level of data in a given time frame.
- Various authentication mechanisms and encryption protocols are supported, such as SSL and SSH data encryption and HTTPS tunneling.
- Ensure full Unicode compliance, enabling efficient retrieval and modification of data in multilingual databases while maintaining linguistic integrity.
- Enjoy a cost-effective solution that provides a reliable and feature-rich driver installation package without the need to deploy and configure any additional software. This in turn significantly reduces deployment costs.
- Run ODBC drivers on popular operating systems such as Windows, macOS, and Linux.
- All data types are supported and can be mapped to ODBC data types.
How to convert Oracle data to MySQL using ODBC
To migrate data from Oracle to MySQL database using ODBC, you need to follow the steps shown in the data migration plan image.
Let's examine each step in detail. Before starting, open dbForge Studio for Oracle and retrieve data from the Oracle sakila.city table, which will be imported into the MySQL table.
![](https://img-blog.csdnimg.cn/img_convert/03c5b74070d9a0e78491db9b78c6243a.png)
Install and configure Oracle's ODBC driver
To convert Oracle data to MySQL, you need to download the Devart ODBC Driver for Oracle on the computer where the data will be migrated .
To install the driver, go to the download folder and double-click the DevartODBCOracle.exe installation file. In the setup wizard that opens , perform the following steps:
- Click Next to start the installation.
- Read and accept the terms of the license agreement.
- Specify the path to the folder where the Devart ODBC Driver for Oracle will be installed.
- Select the components to install. All options are selected by default. If you want to exclude certain components from installation, clear the corresponding check boxes.
- Verify the settings and click Install .
When finished, click Finish to close the installation wizard.
Before you can continue importing data using the ODBC driver, you need to set the Data Source Name (DSN) for the ODBC driver in the Data Source Administrator utility . To open it, type ODBC Data Sources into your computer's search bar and select it. In our example, we use the 64-bit version of the ODBC Data Source Administrator to create the DSN for the ODBC driver.
As you can see, there are two tabs for the data source name:
- A User DSN is accessible to the user who created it in the system.
- Any user logged into the system can access the System DSN. If you want to have unique access, go to User DSN .
In the example we go to the System DSN tab and click Add to create a new data source. In the dialog that opens, select Devart ODBC Driver for Oracle and click Finish .
In the Devart ODBC Driver for Oracle Configuration dialog box, enter a name for the data source and specify the Oracle host name or IP address, port number, database name, user name, and password. Click Test Connection to verify that the connection is properly installed and configured, then click OK on the pop-up window . To save the DSN, click OK .
Note : If the connected user has access to more than one schema, all of those schemas will be visible in the Data Import Wizard in dbForge Studio for MySQL. However, if you want to display a specific Oracle database in Studio, navigate to the Advanced Settings tab and specify the database name in the Schema field. Don't forget to click OK to save the changes.
The created DSN will then appear on the System DSN tab of the ODBC Data Source Administrator utility.
Connect to an Oracle database using ODBC
Now, we can connect to the Oracle database and migrate the data into MySQL tables. Remember, data can be copied to a new or existing database.
To continue, open dbForge Studio for MySQL. In Database Explorer , right-click the database you want to import and select Tools > Import Data .
![](https://img-blog.csdnimg.cn/img_convert/2e389b6a5e1dd0fe19b6ec1d42b4a0b3.png)
In the Data Import Wizard, select ODBC Source File and click Next .
On the ODBC Options page, do the following:
- Under Data Source Specification , select Use system or user data source name , and then select the ODBC driver you created from the drop-down list.
- Under Login Information , enter the user name and password for the Oracle server to which the ODBC driver connects.
- Click Test Connection to verify that the connection was established successfully. Then, click OK to close the popup.
- Click Next to proceed to the next page.
Migrate Oracle schema to MySQL
On the Target page, the Source pane displays the Oracle schema tables to which the connecting Oracle user name has access. The target pane displays MySQL server connections, databases, and tables from which data can be imported.
To import data from Oracle to MySQL, select the source table – sakila.city in our example . By default, the target table will be selected as a new table with the same name. You can also copy data to an existing table in a MySQL database by selecting Existing Table and then selecting the table from the list.
Note: To import specific columns, click Custom Query at the bottom of the Destination page of the Data Import Wizard. In the Source Query dialog box, enter a query in the text field and click OK to retrieve the data to import.
The next step is to switch to the "Mapping" page where you can configure the data type of the column. Here you can see the columns with the specified data type. Additionally, you can preview the table containing the imported data. Since we imported the data into the new table, Studio will automatically create and map all the columns.
However, we can change the data type of a column in a MySQL table. For example, let's set an integer type for the City column. To do this, double-click the data type of the desired column in the "Type" column. In the "Column Properties" dialog box, select the "INT" data type from the "Data Type" drop-down list, and click "OK" to save the changes. Additionally, you can assign primary keys or unique values.
It is important to note that if importing data into an existing table, only columns with the same name will be mapped; the rest should be mapped manually.
![](https://img-blog.csdnimg.cn/img_convert/d7fff8414e24fc0cf0c7830498192511.png)
Migrate data from Oracle to MySQL
When we have finished setting up the schema and tables, we can migrate the data into the tables. In the Data Import Wizard, navigate to the Schemas page that displays the following import schemas:
- Append : Add records to the target table.
- Update : Updates records in the target table with matching records in the source table.
- Append/Update : If the record exists in the target table, update the record; otherwise, add a record.
- Delete : Deletes records in the target table that match records in the source table.
- Repopulate : Deletes all records in the target table and repopulates them from the source.
Depending on whether you're importing data into a new table (like our example) or an existing page, the import pattern for populating the table will vary. For importing data into a new target table, only the Append method can be used. For data import of existing tables, all import methods can be used.
The final step involves selecting the data output method. By default, the Import data directly into the database option is selected and we recommend leaving it as is. Additionally, you can open the data import script in the internal editor for further modification or review or save the script to a file for later use.
Now, click "Import" and view the results. After the data import process is complete, you will see the following:
Click Finish to close the wizard.
To confirm that the data was successfully migrated from the Oracle table to the MySQL table, let's navigate back to the Database Explorer . Then, refresh it to ensure the latest changes are reflected. Expand the oracle_data database, right-click the imported table, and select Retrieve Data . This action fetches data from the MySQL table and verifies that the data in the corresponding Oracle table was imported accurately.
great! The results grid displays data imported from Oracle tables.
We have successfully completed the data migration process from Oracle table to MySQL table. However, let's take a moment to discuss the tools used in this article: dbForge Studio for MySQL and dbForge Studio for Oracle. Both tools are installed using the dbForge Edge installation file.
Benefits of using dbForge Edge instead of a separate studio
A common practice among database developers is to work with different database management systems at the same time. Also, it's even better if the tools cover a wide range of features and functions and meet your requirements. This is important because your day-to-day work may include database development, administration, deployment, testing, performance optimization, data analysis, reporting, and more.
That's why dbForge Edge is a perfect choice compared to dbForge Studio alone. Let's take a look at what this kit can do to improve your productivity day in and day out:
- dbForge Edge includes four ultimate database IDEs with similarly intuitive user interfaces. This reduces the learning curve and increases productivity because developers can use familiar tools and workflows regardless of the underlying database system.
- These IDEs all have comprehensive and versatile powerful functions, including code editing, debugging, schema comparison, data synchronization, data import/export, and more. These tools help developers tackle any database-related tasks and increase development productivity. Work on and improve code quality.
- The bundle allows use with Microsoft SQL Server, MySQL, MariaDB, Oracle, PostgreSQL, and Amazon Redshift. This integration eliminates the need to switch between different tools and allows for seamless cross-database management.
- Integration tools encourage collaboration and knowledge sharing among team members working with multiple databases. This allows easy sharing of database connections, queries, scripts and other artifacts across the team and simplifies teamwork in multi-database environments.
- Finally, you'll be able to save money thanks to dbForge Edge's attractive pricing. A 1-year subscription to the full-featured dbForge Edge Enterprise Edition costs less than the combined price of all four IDEs.
All in all, dbForge Edge provides a general solution for multi-database management that increases productivity, collaboration and efficient database development in different database environments.
in conclusion
In this article, we looked at how to migrate data from Oracle to MySQL tables using the ODBC driver. We demonstrated that the combination of dbForge Studio for MySQL and the ODBC driver is a flexible and easy way to transfer data between different servers. Additionally, the powerful data import functionality available in Studio allows you not only to import data, but also to prepare scripts for future use or to perform testing or debugging operations when required.