How do I list all tables in postgres, across schemas

command-prompt, database-schema, postgresql

Solution

Ask for all tables in all schemas `*`

\dt *.*

Problem

I'm trying to list all tables in a database. \dt isn't doing it, maybe because of name collisions. I've tried many commands, but when two tables in different schemas share a name, only one gets listed by \dt: ``` CREATE DATABASE tester; \c tester CREATE SCHEMA hid1; CREATE SCHEMA hid2; CREATE TABLE a (a int); CREATE TABLE b (a int); CREATE TABLE hid1.a (a int); CREATE TABLE hid1.b (a int); CREATE TABLE hid1.c (a int); CREATE TABLE hid2.a (a int); CREATE TABLE hid2.d (a int); \dt SET search_path TO public,hid1,hid2; \dt SET search_path TO hid1,public,hid2; \dt SET search_path TO hid2,hid1,public; \dt ``` i.e. ``` tester=# \dt List of relations Schema | Name | Type | Owner --------+------+-------+------- hid1 | a | table | bob hid1 | b | table | bob hid1 | c | table | bob hid2 | d | table | bob (4 rows) tester=# SET search_path TO hid2,hid1,public; SET tester=# \dt List of relations Schema | Name | Type | Owner --------+------+-------+------- hid1 | b | table | bob hid1 | c | table | bob hid2 | a | table | bob hid2 | d | table | bob (4 rows) ``` See how three tables are being masked? My understanding is that schemas are namespaces. Is that where I'm going wrong? Am I missing something?

Original source