Converting from other Databases to PostgreSQL
From PostgreSQL wiki
Contents |
Non-specific
- Ispirer MnMTK Ispirer Migration and Modernization Toolkit (Ispirer MnMTK) performs automatic migration of any popular RDBMS to PostgreSQL.
- Full Convert Database conversion from more than 30 database engines to PostgreSQL and back.
- pgloader knows how to load data from MySQL, SQLite, MS SQL Server, dBase files, CSV files and fixed-width data files, and more. Released under The PostgreSQL Licence.
- DBConvert PostgreSQL database migration and sync software Database conversion and synchronization between PostgreSQL/ Amazon RDS, MySQL, MS SQL Server, SQL Azure, Oracle, MS Access.
- Converting data between PostgreSQL and others database formats ESF Database Migration Toolkit enables you to transfer data across various databases, supporting PostgreSQL, MySQL, Oracle, SQL Server, IBM DB2, Informix, Microsoft Access, Microsoft Excel, dBase, Foxpro, Firbird, SQLite etc. - by Martin Williams
- Comparison of different SQL implementations by Troels Arvin (covers PG 8.4 and MySQL 5.0)
- Transactional DDL in PostgreSQL: A Competitive Analysis by Greg Smith
- Migrating from one database to another with Pentaho ETL by Nicola Benaglia
- dataPro Conversion tool for PostgreSQL, SQLite, MySQL, Oracle, SQL Server and Microsoft Access. Transfer database objects between different databases and servers, convert tables schema and migrate data from one database type to another.
- DataDiff CrossDB is a Windows GUI utility to compare and synchronize/transfer data from PostgreSQL to/from Oracle, MSSQL, MS Access or MySQL databases.
- PostgreSQL Data Wizard is a Windows GUI utility to transfer both schema and data from any ADO-compatible source (like MS Access, MySQL, SQL Server, Oracle, etc) to PostgreSQL.
- SQL::Translator is a Perl module for translating table definitions between different software.
- Foreign data wrappers may be useful for exporting data from other databases
- Postgres Migration Toolkit Software pack to convert Oracle, MySQL, SQL Server and FoxPro to PostgreSQL, and vice versa.
- sqlacrossover SQLAlchemy-based cross-database migration tool
- Skyvia Web service for cloud data integration for PostgreSQL with Salesforce, Dynamics CRM, SugarCRM, Zoho CRM, QuickBooks, FreshBooks, ExactTarget, MailChimp, Bigcommerce, MySQL, SQL Server, SQL Azure, Amazon RDS.
- OmniDB Open source full-featured web tool for database management. Currently supports PostgreSQL only. More RDBMS support coming soon, including the ability of converting databases from any supported RDBMS to PostgreSQL and back.
- Exportizer Enterprise Universal data conversion tool for PostgreSQL, Oracle, SQL Server, SQLite, Interbase, Firebird, MySQL, DB2, Informix, SQL Anywhere, Microsoft Access, Microsoft Excel, dBase, CSV. Can export data either from GUI or from command line.
Apache Derby
- derby2pg Converter program that will convert the tables, data and indexes in a given schema to a script that can be used to populate a PostgreSQL database.
DBase II, III, IV+ / DBF Format
- FoxPro-to-PostgreSQL a program to migrate FoxPro databases to PostgreSQL server. The program does not use ODBC or any other middleware software. Command line support allows to script, automate and schedule the conversion process.
- Full Convert Database conversion from DBF (dBase, Clipper, Visual FoxPro and other DBF variants) to PostgreSQL and back
- pgloader by Dimitri Fontaine
- Convert .dbf files into PostgreSQL by Tomasz Judycki
- A Visual Basic utility to convert Dbase III, IV, and V by Dennis Bazan
- Porting data from dBASE IV to PostgreSQL by Vijay Deval (2002-09-07)
- PgDBF : Simplified and optimized replacement for XBaseToPg by Kirk Strauser
- Exportizer Pro Converts data from dBase to PostgreSQL and back.
FileMaker Pro
- Porting from FileMaker Pro to PostgreSQL by Michelle Murrain (24th August 2001)
IBM DB2
- Ispirer MnMTK Ispirer Migration and Modernization Toolkit (Ispirer MnMTK) automatically migrates the entire database schema (tables, views, stored procedures, functions, triggers, etc.) and transfers data from DB2 LUW, DB2 AS/400 (iSeries) and DB2 OS/390 (z/OS) to PostgreSQL.
- Migrating from DB2 to PostgreSQL
- Full Convert Database conversion from more than 30 database engines, including IBM DB2, to PostgreSQL and back.
- db2topg Migration tool to convert a DB2 UDB Database into a PostgreSQL database.
- Exportizer Enterprise Converts data from DB2 to PostgreSQL and back.
InterBase
- Ispirer MnMTK Ispirer Migration and Modernization Toolkit (Ispirer MnMTK) automatically migrates the entire database schema (tables, views, stored procedures, functions, triggers, etc.) and transfers data from InterBase as well as Firebird to PostgreSQL.
- DBReplicate - Simplify Interbase->PostgreSQL conversions by Kirk Strauser
- Full Convert Database conversion from more than 30 database engines, including Interbase, to PostgreSQL and back
- Exportizer Enterprise Converts data from Interbase to PostgreSQL and back.
Microsoft Access
- Linking to MS Access tables with ogr_fdw If your PostgreSQL is on windows, you can use ogr_fdw foreign data wrapper, packaged with PostGIS 2.2+ bundle for windows via application stackbuilder. With PostgresQL 9.5, you can use IMPORT FOREIGN SCHEMA to link in all the MS access tables and then cherry pick how you want to restructure.
- exportSQL - a Microsoft Access module which exports Access Database into MySQL, mSQL and PostgreSQL by Dobrica Pavlinusic. Based on the work of Pedro Freire
- Full Convert Database conversion from more than 30 database engines, including Access, to PostgreSQL and back
- Exportizer Enterprise Converts data from MS Access to PostgreSQL and back.
- MDB Tools by Brian Bruns
- A quick way to dump all tables as tsv or csv files
for TT in $(mdb-tables file.mdb); do
mdb-export -Q -d '\t' -D '%Y-%m-%d %H:%M:%S' file.mdb "$TT" > "${TT}.tsv"
done
for TT in $(mdb-tables file.mdb); do
mdb-export -D '%Y-%m-%d %H:%M:%S' file.mdb "$TT" > "${TT}.csv"
done
If the tablenames have embedded spaces...
mdb-tables -1 file.mdb| while read TT
do
mdb-export -D '%Y-%m-%d %H:%M:%S' file.mdb "$TT" > "${TT}.csv"
done
A shell script that may be useful for converting entire databases:
#!/bin/sh -e
mdbfn=$1
schemafn=$2
fkfn=$3
datafn=$4
schema=$5
tf=$(tempfile)
pre=""
[ -n "${schema}" ] && pre="\"${schema}\"."
mdb-schema "${mdbfn}" postgres > "${tf}"
# Schema file
echo "BEGIN;\n" > "${schemafn}"
sp=""
[ -n "${schema}" ] && echo "CREATE SCHEMA \"${schema}\";\n" >> "${schemafn}"
[ -n "${schema}" ] && sp="SET search_path = \"${schema}\", pg_catalog;\n"
echo ${sp} >> "${schemafn}"
awk '($0 !~ /^ALTER TABLE.*FOREIGN KEY.*REFERENCES/) {print;}' "${tf}" >> "${schemafn}"
echo "\nEND;" >> "${schemafn}"
# Foreign keys file
echo "BEGIN;\n" > "${fkfn}"
echo ${sp} >> "${fkfn}"
awk '($0 ~ /^ALTER TABLE.*FOREIGN KEY.*REFERENCES/) {print;}' "${tf}" >> "${fkfn}"
echo "\nEND;" >> "${fkfn}"
# Data file
echo "BEGIN;\n" > "${datafn}"
echo "SET CONSTRAINTS ALL DEFERRED;\n" >> "${datafn}"
mdb-tables -1 "${mdbfn}" | while read TT
do
mdb-export -Q -d '\t' -D '%Y-%m-%d %H:%M:%S' "${mdbfn}" "$TT" > "${tf}"
awk -v pre="${pre}" -v TT="${TT}" \
'(NR==1) {gsub(/\t/,"\",\""); print "COPY " pre "\"" TT "\"(\"" $0 "\") FROM stdin;";}' "${tf}" >> "${datafn}"
awk '(NR>1) {gsub(/\t\t/,"\t\\N\t"); gsub(/\t$/,"\t\\N"); gsub(/\t\t/,"\t\\N\t"); print;}' "${tf}" >> "${datafn}"
echo "\\.\n" >> "${datafn}"
done
echo "END;" >> "${datafn}"
rm -f "${tf}"
If this script is saved to the file access2psql.sh and made executable, then it would be used as follows:
access2psql.sh file.mdb schema.sql foreignkeys.sql data.sql pg_schema_name psql -f schema.sql pg_db_name psql -f data.sql pg_db_name psql -f foreignkeys.sql pg_db_name
This script won't work properly if there are tab characters in text columns, though the call to mdb-export could be modified to export INSERT statements to fix this. Also, mdb-schema has trouble representing multi-column foreign keys, so foreignkeys.sql may need some manual editing.
- Export Microsoft Access to PostgreSQL. Cross database synchronization
- Importing Microsoft Access MDB into PostgreSQL on Linux by Michael Olschimke
- Microsoft Access to PostgreSQL Conversion by Jon Hutchings (2001-07-20)
- access2pgsql tool by Mariano Reingart
- Using MS Access as front end and PostgreSQL as back-end database by PostgresOnLine Journal - 2008-01-31
Microsoft SQL Server
- Ispirer MnMTK Ispirer Migration and Modernization Toolkit (Ispirer MnMTK) automatically migrates the entire database schema (tables, views, stored procedures, functions, triggers, etc.) and transfers data from Microsoft SQL Server to PostgreSQL.
- MSSQL-to-PostgreSQL is a migration utility to convert SQL Server or SQL Azure databases to PostgreSQL. Option to filter data using SELECT-queries, synchronization mode, command line support.
- Full Convert Database conversion from more than 30 database engines, including SQL Server, to PostgreSQL and back
- sqlserver2pgsql Migration tool to convert a Microsoft SQL Server Database into a PostgreSQL database
- pgloader by Dimitri Fontaine
- DBConvert for PostgreSQL and MS SQL Server Conversion and Sync software solutions for cross database migration between PostgreSQL/ Amazon RDS and MS SQL Server/ SQL Azure
- Learning PostgreSQL (Alexander Kuznetsov) - series of blog articles for SQL Server users (2013-10 ~ 2013-11)
- Converting SQL Server Table Structure to PostgreSQL Leo Hsu and Regina Obe (2011-09-03)
- Conversion of Microsoft SQL/ASP applications to PostgreSQL by Ethan Townsend (2005-06-23)
- Converting your data from MS SQL Server 7 to PostgreSQL 7.1.x by Ryan C. Bonham (2002-01-05)
- Microsoft SQL Server to PostgreSQL Migration by Ian Harding (2001-09-17)
- Compare SQL Server 2008 R2, Oracle 11G R2, PostgreSQL/PostGIS 1.5 Spatial Features BostonGIS (2010-06-01)
- Cross Compare of SQL Server 2005, MySQL 5, and PostgreSQL 8.3 by Leo Hsu and Regina Obe (2008-05-13)
- Cross Compare of SQL Server 2008, MySQL 5.1, and PostgreSQL 8.4 by Leo Hsu and Regina Obe (2009-08-15)
- Universal Unique Identifiers PostgreSQL SQL Server Compare Demonstrates how to implement SQL Server NEWID() GUID uniqueidentifier type in PostgreSQL by Leo Hsu and Regina Obe (2010-10-07)
- Exportizer Enterprise Converts data from SQL Server to PostgreSQL and back.
MySQL
Scripts, programs
pg_chameleon is a python procedure which replicates MySQL into PostgreSQL. The tool can detach the replica for minimal downtime migrations.
pgloader supports full migration of the database schema and data from a single command line and provides a command language for more complex or specific scenarios. It is still fully supported: please report any bugs on its GitHub page. It appears in the 2013 section here because that's when it has been published first.
2015
- MySQL-to-PostgreSQL is a program to migrate MySQL databases to PostgreSQL server. Option to filter data using SELECT-queries, synchronization mode, command line support.
- FromMySqlToPostgreSql migration tool by Anatoly Khaytovich, provides an accurate migration of table data, indices, PKs, FKs... Makes an extensive use of PostgreSQL COPY protocol.
2014
- MySQL/PostgreSQL Converter from Mihail Shumilov, written on PHP. Supported big DB
2013
- MySQL/PostgreSQL Converter from Lanyrd, based on work detailed here
- pgloader, from Dimitri Fontaine, based on work detailed here and Migrating Sakila from MySQL to PostgreSQL
- py-mysql2pgsql, example use case here
- MyETL, Tool that works with the MySQL FDW
Previously
- Ispirer MnMTK Ispirer Migration and Modernization Toolkit (Ispirer MnMTK) automatically migrates the entire database schema (tables, views, stored procedures, functions, triggers, etc.) and transfers data from MySQL to PostgreSQL.
- Free MySQL to Postgres Migration Wizard by EnterpriseDB v1.1 by EnterpriseDB Corporation. Available without registration via PostgreSQL installer wizard.
- Conversion tool for migrating from MySQL to PostgreSQL by PostgreSQL Inc.
- Converting MySQL to PostgreSQL - from en.wikibooks.org
- Migrate MySQL to PostgreSQL. - Cross database bidirectional synchronization
- my2pg.pl - A Perl script used to convert a MySQL database dump to PostgreSQL-compatible format, by Maxim Rudensky and Valentine Danilchuk
- mysql2pgsql - A Perl script used to convert MySQL databases dump to a PostgreSQL-compatible format
- MySQL PHP to PostgreSQL by Michael Kohn
- PHP_my2pg PHP script by Gabriel Bordeaux
- Migrating from MySQL to Postgresql with Django blogpost by alejandro
- Migrates MySQL to PostgreSQL Ruby script by Max Lapshin
# To install mysql2psql (under ubuntu 11.10): No need to get from github, just: sudo apt-get install ruby gems libmysqlclient-dev libpq-dev gem install mysql pg mysql2psql # To get info about the mysql socket: netstat -l | grep mysql mysql2psql # creates a .yml templae vi mysql2psql.yml # edit the template mysql2psql # connects to mysql database and write into postgres database
- py-mysql2pgsql Python script to convert MySQL database to PostgreSQL compatible file or export directly to a PostgreSQL server
- my2pg.py MySQL to PostgreSQL database conversion (not the same as above)
- SQL Data Definition Language (DDL) Conversion to MySQL, PostgreSQL and MS-SQL by phpBB Group
- Exportizer Enterprise Converts data from MySQL (32-bit) to PostgreSQL and back.
Documentation
- Backend Database Switcheroo Howto Part I by Nathan Matias
- Backend Database Switcheroo Howto Part II by Nathan Matias
- How-To: Migrating from MySQL to PostgreSQL by Zach Beane
- Things to find out about when moving from MySQL to PostgreSQL by Joel Burton (8th April 2001)
- Why PostgreSQL Instead of MySQL: Comparing Reliability and Speed in 2007 by Greg Smith
- Cross Compare of SQL Server, MySQL, and PostgreSQL by Leo Hsu and Regina Obe (2008-05-13)
- How to make a proper migration from MySQL to PostgreSQL
- Migrating a community platform from Mysql to PostgreSQL by Andreas Scherbaum (Prato, 2007)
- MySQL functions for PostgreSQL by Pavel Stěhule
Oracle
Utilities, tools, scripts etc.
- Ispirer MnMTK Ispirer Migration and Modernization Toolkit (Ispirer MnMTK) automatically migrates the entire database schema (tables, views, packages, stored procedures, functions, triggers, etc.) and transfers data from Oracle to PostgreSQL.
- Full Convert Database conversion from more than 30 database engines to PostgreSQL and back
- Database migration for Oracle and PostgreSQL Software for cross - database conversion and sync between Oracle and PostgreSQL.
- Ora2Pg - Oracle to PostgreSQL database schema converter by Gilles Darold
- PostgreSQL Foreign Data Wrapper for Oracle (oracle_fdw) - an FDW providing support to access Oracle databases from within PostgreSQL
- Orafce - implements common Oracle functions in PostgreSQL for compatibility
- Oracle-to-PostgreSQL - a program to migrate Oracle databases to PostgreSQL server. The program has high performance due to direct connection to data source and destination databases (it does not use ODBC or any other middleware software). Command line support allows to script, automate and schedule the conversion process.
- AWS Schema Conversion Tool - to convert your existing database schema from one database engine to another (free download).
- Exportizer Enterprise Converts data from Oracle to PostgreSQL and back.
Documentation, articles, presentations etc.
PostgreSQL documentation
Articles and presentations (in reverse chronological order)
- From MySQL to PostgreSQL with pgloader (English) talk at PostgreSQL Conference Europe, Dimitri Fontaine, 2013-10-29
- Analysis and Planning Process for Migration from Oracle 10g R2 to PostgreSQL 9.1.3 (Spanish) by the Spanish National Competence Center for the Application of Opensource Technologies (CENATIC) (2012-06)
- Compare SQL Server 2008 R2, Oracle 11G R2, PostgreSQL/PostGIS 1.5 Spatial Features BostonGIS (2010-06-01)
- Migrating Oracle Databases to PostgreSQL using Xen on Debian GNU/Linux by Raj Mathur (Kandalaya) (2008-12-26)
- Porting Oracle Applications to PostgreSQL by Peter Eisentraut (PGCon 2008)
- PostgreSQL for Oracle DBAs by Richard Stephan (2007-06-01)
- Porting JDBC applications from Oracle to PostgreSQL by Chris Drawater (2006-03-24)
- Related documents for J2EE, Tomcat, and Oracle migrations by Chris Drawater (2007-01-15)
- Interview with Mark Stosberg (From Oracle/tcl to PostgreSQL/Perl) by Robert Treat (2004-10-24)
- Oracle to Postgres Conversion by James Shannon, Ben Adida, and Don Baccus
Progress RDBMS
- Convert Progress RDBMS to PostgreSQL by Tomasz Judycki
Utilities, tools, scripts etc.
- Ispirer MnMTK Ispirer Migration and Modernization Toolkit (Ispirer MnMTK) automatically migrates the entire database schema and transfers data from Progress to PostgreSQL.
Converting PostgreSQL Databases to other Databases
- Ispirer MnMTK Ispirer Migration and Modernization Toolkit (Ispirer MnMTK) performs automatic migration of PostgreSQL to any popular RDBMS.
- PostgreSQL to InterBase dump file converter by Dobrica Pavlinusic
- Full Convert Database conversion from PostgreSQL to more than 30 database engines
- OmniDB Open source full-featured web tool for database management. Currently supports PostgreSQL only. More RDBMS support coming soon, including the ability of converting databases from any supported RDBMS to PostgreSQL and back.
- Exportizer Enterprise Supports data conversion from PostgreSQL to Oracle, SQL Server, SQLite, Interbase, Firebird, MySQL, DB2, Informix, SQL Anywhere, Microsoft Access, Microsoft Excel, dBase, Paradox, CSV.