Migrating one database to another actually involves migrating the schemas, tables, and data. The software itself is not migrated.
Database migration could be homogeneous or heterogeneous. Homogeneous migration of a database is migration from one platform to another, such as from a local platform to a cloud platform. Heterogeneous migration is migration to a completely different database engine, such as from PostgreSQL to MySQL, or from a relational database to a NoSQL database.
There are several reasons you’d migrate a database:
Whatever the reason, there are several things you should take into consideration first.
One of the most important choices in migrating a database is that what type of database objects (tablespaces, schemas, tables) are to be migrated. When migrating complete tablespaces, schemas, and tables, the DDL (Data Definition Language) for each database needs to generated. If data is to be migrated too, the DML (Data Manipulation Language) for tables also needs to be generated.
SQL Syntax, both for DDL and DML statements, could be slightly different between the source and target databases. The DDL and DML generated on one database engine may not run as such on another database engine, so the SQL statements need to be mapped from one to the other.
Data types for source and target databases could be different. For example, MySQL does not support a Boolean data type. When mapping a Boolean or bool data type from another database engine, the equivalent in MySQL is TINYINT(1). Numeric and fixed data types are mapped to DECIMAL in MySQL.
Tablespace, schema, table, and column names may need to be transformed if one database supports case-sensitive names and another doesn’t. For example, MySQL converts all table names to lowercase on storage and lookup. Other transformations that could be applied are renaming a database object (schema, table, or column), adding or dropping a table column, and adding a prefix or suffix to a database object name.
Another migration consideration is preparation of the target tables. Several options could be used if target tables already exist:
Database migration is typically performed with a migration tool or service. But before you start migration, explore your options and take these considerations into account.