Just another software engineer

Commands Conversion Table From MySQL to PostgreSQL

Feb10th, 20131:00 pm

A lot of companies are moving or considering moving to PostgreSQL today. The reasons vary a lot and it is not the scope
of this blog post to address those reasons, but to help the developers to do an easier adoption of new technology by
showing a simple command conversion table.

Although the blog title says MySQL to PostgreSQL, it can serve as a reverse path (PostgreSQL to MySQL). So, here it is:

MySQL command

PostgreSQL equivalent

show databases;

\\l

use somedb;

\\c somedb

show tables;

\\dt

describe table sometable;

$ pg_dump -U postgres -t mytable --schema-only mydb

show schemas

\\dn

Some notes

There’s a lot of differences between MySQL to PostgreSQL. Some you need to address every single time (like the
differences between commands I’ve pointed out). Others are less frequent, like creating databases, users or setting up a
replication.

If you are planning to learn or move to PostgreSQL from MySQL, I’d like to recommend that you learn the differences
between authentication, which includes creating and giving priveleges to users and creating databases. It should be good
enough for small to medium setups.

Any important command that I’ve missed? Please, drop a line in the comments :-)