11 Sep

mysql vs pgsql

I’m doing a bit of work for a company, which involves working with PGSQL instead of MySQL, as I usually do.

I know this is a religious issue for some people, but I’m finding PGSQL to be a bit …abstruse. It’s not the SQL – that’s pretty-much the same, but the local commands are just baffling.

For example, in order to open up the console command, in MySQL you type “mysql“, but in PGSQL, you type “psql” – huh?

To see a list of the database’s tables in MySQL, you type “show tables“. In PGSQL, you type “SELECT tablename FROM pg_tables WHERE tableowner = current_user“, which doesn’t always work – huh?

To see details of the various fields in a table, in MySQL, you type “describe the_table“. In PGSQL, you type “SELECT attnum,attname from pg_class, pg_attribute WHERE relname='the_table' AND pg_class.oid=attrelid AND attnum > 0” – huh?

I hope it all becomes clear, or this could be a long day…

4 thoughts on “mysql vs pgsql

  1. \dt on the command line to show all tables of current database
    (\d to show tables, sequences etc)
    \d to show table details

  2. Yeah, ‘man psql’ or even typing ‘?’ while in psql are incredibly unobvious things to do – far more so than figuring out which postgres system tables hold what information.. 😉

Comments are closed.