psql \dt and identical table names across multiple schemas

Started by Murat Tasanover 17 years ago2 messagesgeneral
Jump to latest
#1Murat Tasan
murat.tasan.cwru.edu@gmail.com

This may have been brought up before, but if not, I thought I would bring it
to attention, as I think this would be an easy fix.
The problem: 2 (or more) schemas that have an identical table name.

From within psql, the \dt (and variants of it) will only show a single

version of that table.

example input:

CREATE SCHEMA schema1;
CREATE TABLE schema1.tableX (id integer);
CREATE TABLE schema1.tableY (id integer);
CREATE SCHEMA schema2;
CREATE TABLE schema2.tableX (id integer);
CREATE TABLE schema2.tableZ (id integer);
set search_path to schema1, schema2;
\dt

example output from \dt command:

schema1 | tablex | table | username
schema1 | tabley | table | username
schema2 | tablez | table | username

It seems to me, that if the schemas are even listed in the output of the \dt
command, all identically-named tables should be listed.
In fact, showing the schema name but not showing all the tables becomes
non-intuitive and somewhat misleading.

Thoughts?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Murat Tasan (#1)
Re: psql \dt and identical table names across multiple schemas

"Murat Tasan" <murat.tasan.cwru.edu@gmail.com> writes:

This may have been brought up before, but if not, I thought I would bring it
to attention, as I think this would be an easy fix.
The problem: 2 (or more) schemas that have an identical table name.
From within psql, the \dt (and variants of it) will only show a single
version of that table.

That is intentional. Use \dt *.foo if you want to see all the tables
named foo.

regards, tom lane