Porting Mysql Database to Postgresql_mysql

Source: Internet
Author: User
Tags postgresql
In North America, People's enthusiasm for PostgreSQL is rising. With the development of PostgreSQL, PostgreSQL 8.x has been technically beyond MySQL 5.x, and the market beyond belief is only a matter of time. Ultimately, it may not be possible for users to have access to an Open-source database comparable to Oracle.
I work in the Internet company, services about 500,000 business users, after several upgrades to the transplant, the company has all the background database from MySQL to PostgreSQL, and the individual completed half of the database transplant, so the database from MySQL to the PostgreSQL Have accumulated some experience. In this writing, I hope to be able to use PostgreSQL some inspiration.
1 Preparation: Use the MySQL Data Backup tool to make a full backup of the database:
MYSQLDUMP-H [hostname]-u [username]-p [Password]--extended-insert=false [dbname] > Mysql-db.sql
Note Disable Extended-insert, PostgreSQL does not support MySQL Extended-insert
2) Transformation: Convert Mysql-db.sql to PostgreSQL SQL Script that can be imported.
MySQL and PostgreSQL in the SQL semantics of a certain difference, such as MySQL does not support sequence, triggers and other functions, but for this also provides some of its own grammar rules, and compared to some system functions, MySQL and PostgreSQL there are relatively large differences. To this end, I wrote a semantic analysis and transformation of the program Mysql2psql
>mysql2psql Mysql-db.sql Postgres-db.sql
3) Import: Use the pgadmin provided by PostgreSQL to import data files into the database.
4 Modification of SQL statements: In the practical application, the front-end system will often embed some SQL statements with database characteristics, and with the background database changes, the front-end system program also needs to make corresponding changes.
The most common differences between MySQL and PostgreSQL include: Group by,join usage differences, system function naming and invocation differences, and so on.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.