Posted over 8 years ago. Visible to the public.

PostgreSQL cheat sheet for MySQL lamers

So you're switching to PostgreSQL from MySQL? Here is some help...

General hints on PostgreSQL

  • \? opens the command overview
  • \d lists things: \du lists users, \dt lists tables etc

Command comparison

Description MySQL command PostgreSQL equivalent
Connect to the database mysql -u $USERNAME -p sudo -u postgres psql
Show databases SHOW DATABASES; \l[ist]
Use/Connect to a database named 'some_database' USE some_database; \c some_database
Show tables/relations within one database SHOW TABLES; \dt
Show table details (columns, types) DESCRIBE some_table; \d+ some_table
Show indices of some_table (in case of MySQL) and all indices of database (PostgreSQL) SHOW INDEX FROM some_table; \di
Create user that can create databases CREATE USER harry IDENTIFIED BY 'foo'; CREATE ROLE username WITH createdb LOGIN [PASSWORD 'password'];
Change password of an existing user ... ALTER ROLE username WITH PASSWORD 'password';
Grants access to a database. GRANT ALL PRIVILEGES ON database.* TO username@localhost; GRANT ALL PRIVILEGES ON DATABASE database TO username;
Grants access to create databases. ? ALTER USER username CREATEDB;
Expanded table formatting mode (pretty print) YOUR QUERY\G; \x on

Further reading

Flaky tests are tests that sometimes fail for no obvious reason. They are the plague of many end-to-end (E2E) test suites that automate the browser through tools like Capybara and Selenium.

Join our free training event and learn to fix any flaky test suite, even in large legacy applications.

Owner of this card:

Thomas Eisenbarth
Last edit:
over 2 years ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Thomas Eisenbarth to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more