Oracle DBMS is a well-known player on the market of high load corporate warehouses. This is not surprising that it comes with quite restricted licenses and high-priced total cost of ownership (TCO). Long term trend of reducing corporate expenses for IT infrastructure forces many companies to migrate their databases to more affordable platforms.
MySQL is another advanced database management system that often considered as alternative for Oracle due to similar capabilities of both systems (also, the same seller and support provider). Oracle provides such valuable features as multi-level compression, wide range of backup options and storage customization. Having all these features, MySQL extends capabilities by tight web integration, easy start for development and administration, huge community of developers and administrator working at more affordable rates than Oracle specialists. This allows to consider MySQL as ideal choice for projects demanding high data integrity, reliability and efficiency.
Despite of the approach being used to migrate from Oracle to MySQL, there are following stages that must be implemented:
- Oracle schemas and table definitions are exported into ‘CREATE SCHEMA’ and ‘CREATE TABLE’ statements, providing safe type mapping and proper conversion of the related attributes
- Those SQL-statements are converted according to the target syntax and imported into MySQL database
- Oracle data is exported into CSV files (one file per table), binary and non-standard data must be dumped into hexadecimal representation
- The output CSV files are post-processed to comply with MySQL format (when it is necessary) and imported into the target database
- Oracle views, stored procedures, functions and triggers are extracted in forma of SQL statements and source code.
- Those SQL statements and source code are transformed to comply with MySQL syntax paying attention to system built-in functions and then load to target server. Since MySQL does not provide capabilities similar to Oracle packages, global variables inside packages must be migrated into data of the special service table.
Table Definitions
Below we explore all steps required to migrate Oracle to MySQL in details. Oracle lists all tables available for the current user through the following SELECT-query to system table ‘user_tables’:
SQL> select table_name from user_tables;
Definition of the specified table is extracted as follows below. First two statements are used to set screen buffer large enough to fit the entire table definition. If it is not enough for particular table, increase th volume:
SQL> set long 2000 SQL> set pagesize 0 SQL> select DBMS_METADATA.GET_DDL('TABLE',