2

In MySQL document, it lists SHOW statements (for tables, databases, ...) in "SQL".

But PostgreSQL doesn't have SHOW or equivalent statement in PL/pgsql. Only psql has some client-side commands for the same purpose.

So I was wondering whether SHOW statements are in SQL, or in MySQL's SQL dialect?

Thanks

Tim
  • 1
  • 141
  • 372
  • 590
  • If you need to do it in SQL you'd query the system tables. There's an option for `psql` that will show you the SQL behind `\dt` and friends, just check the [other answers](https://stackoverflow.com/a/11286777/479863) to the question you linked to. – mu is too short Jun 14 '18 at 01:30

2 Answers2

3

Postgres has a show statement, but it is for a different objective than MySQLs. I wouldn't worry about what is and isn't valid SQL; the only thing I would concern myself with is what variant I'm dealing with here.

hd1
  • 33,938
  • 5
  • 80
  • 91
  • Thanks. I am concerned about if SQL has statement for showing tables, databases, ... – Tim Jun 14 '18 at 00:41
  • Now you seem to be asking for something else maybe "SELECT datname FROM pg_database ;" ?? Please list specifically if you can't find what you need. Cheers .. – Slumdog Jun 14 '18 at 03:15
  • \? will list what's available. – hd1 Jun 14 '18 at 09:11
3

There is no SHOW command in standard SQL, so the MySQL and PostgreSQL SHOW commands are quite different.

If you need a standard conforming way to get table metadata, you should query the tables and views in the information_schema.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263