PostgreSQL SHOW TABLES Equivalent (psql)

MySQL and MariaDB have a SHOW TABLES statement, which outputs a list of tables and views in a database. PostgreSQL doesn’t have a SHOW TABLES statement, but it does have a command that produces a similar result.

In Postgres, you can use the \dt command to show a list of tables. This is a psql command (psql is the interactive terminal for PostgreSQL).

Continue reading

Fix “ERROR: each INTERSECT query must have the same number of columns” in PostgreSQL

When using PostgreSQL’s INTERSECT operator, if you encounter an error that reads “ERROR: each INTERSECT query must have the same number of columns“, it’s because there’s a mismatch in the number of columns returned by the queries on either side of the INTERSECT operator.

The way to fix this is to ensure that both SELECT statements return the same number of columns.

Continue reading

Fix “ERROR:  each EXCEPT query must have the same number of columns” in PostgreSQL

When using PostgreSQL’s EXCEPT operator, if you encounter an error that reads “ERROR:  each EXCEPT query must have the same number of columns“, it’s because there’s a mismatch in the number of columns returned by the queries on either side of the EXCEPT operator.

The way to fix this is to ensure that both SELECT statements return the same number of columns.

Continue reading