This is a short table of useful and common MySQL & PostgreSQL commands put up against each other.
MySQL |
PostgreSQL |
|
| Command line client | mysql | psql |
| Connect to database | use mysql; | \connect postgresql; |
| List databases | show databases; | \l |
| List tables | show tables; | \dt |
| Describe table | describe table; | \d table; |
| Show server version | select version(); | select version(); |
| Show the current time | select now(); | select now(); |
| Authentication | GRANT ALL PRIVILEGES ON *.* TO ‘monty’@’localhost’; (http://dev.mysql.com/doc/refman/5.5/en/adding-users.html) | Edit pg_hba.conf (http://wiki.postgresql.org/wiki/Client_Authentication) |
| Check user privileges | SHOW GRANTS FOR ‘root’@’localhost’; | \du (List all users and their permission levels) |
| Backup | mysqldump [options] db_name [tbl_name …] | pg_dump [option…] [dbname] |
Note for future: This reference list will grow.

Recent Comments