Thread: \d don't print all the tables

\d don't print all the tables

From
"Wen Yi"
Date:
Hi community,
here's my shell:

postgres=# \d
Did not find any relations.
postgres=# create schema namespace_a;
CREATE SCHEMA
postgres=# create schema namespace_b;
CREATE SCHEMA
postgres=# create table simple (name varchar);
CREATE TABLE
postgres=# create table namespace_a.simple (name varchar);
CREATE TABLE
postgres=# create table namespace_b.simple (name varchar);
CREATE TABLE
postgres=# \d
         List of relations
 Schema |  Name  | Type  |  Owner   
--------+--------+-------+----------
 public | simple | table | postgres
(1 row)

postgres=#

I think it should print the table on namespace_a & namespace_b, not just public, it really confused me.
Can someone give me some advice?

Yours,
Wen Yi.

Re: \d don't print all the tables

From
Antonio Čale
Date:
Hi,

try: \d *.*
where: *.* = schema.table

Best regards /
Cordialement / S pozdravem / S poštovanjem,
Antonio Čale


On Mon, Jul 24, 2023 at 11:43 AM Wen Yi <wen-yi@qq.com> wrote:
Hi community,
here's my shell:

postgres=# \d
Did not find any relations.
postgres=# create schema namespace_a;
CREATE SCHEMA
postgres=# create schema namespace_b;
CREATE SCHEMA
postgres=# create table simple (name varchar);
CREATE TABLE
postgres=# create table namespace_a.simple (name varchar);
CREATE TABLE
postgres=# create table namespace_b.simple (name varchar);
CREATE TABLE
postgres=# \d
         List of relations
 Schema |  Name  | Type  |  Owner   
--------+--------+-------+----------
 public | simple | table | postgres
(1 row)

postgres=#

I think it should print the table on namespace_a & namespace_b, not just public, it really confused me.
Can someone give me some advice?

Yours,
Wen Yi.

Re: \d don't print all the tables

From
Ron
Date:
On 7/23/23 21:25, Wen Yi wrote:
> Hi community,
> here's my shell:
>
> postgres=# \d
> Did not find any relations.
> postgres=# create schema namespace_a;
> CREATE SCHEMA
> postgres=# create schema namespace_b;
> CREATE SCHEMA
> postgres=# create table simple (name varchar);
> CREATE TABLE
> postgres=# create table namespace_a.simple (name varchar);
> CREATE TABLE
> postgres=# create table namespace_b.simple (name varchar);
> CREATE TABLE
> postgres=# \d
>          List of relations
>  Schema |  Name  | Type  |  Owner
> --------+--------+-------+----------
>  public | simple | table | postgres
> (1 row)
>
> postgres=#
>
> I think it should print the table on namespace_a & namespace_b, not just 
> public, it really confused me.
> Can someone give me some advice?

Add namespace_a and namespace_b to your search_path.  Then it will work.

Off the top of my head:
SET search_path = namespace_a, namespace_b, public;

-- 
Born in Arizona, moved to Babylonia.



Re: \d don't print all the tables

From
Adrian Klaver
Date:
On 7/23/23 19:25, Wen Yi wrote:
> Hi community,
> here's my shell:

> I think it should print the table on namespace_a & namespace_b, not just 
> public, it really confused me.
> Can someone give me some advice?

Read about search_path:

https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PATH

> 
> Yours,
> Wen Yi.

-- 
Adrian Klaver
adrian.klaver@aklaver.com




Re: \d don't print all the tables

From
Alvaro Herrera
Date:
On 2023-Jul-24, Ron wrote:

> Add namespace_a and namespace_b to your search_path.  Then it will work.
> 
> Off the top of my head:
> SET search_path = namespace_a, namespace_b, public;

Actually it won't, because the table in the earliest schema "shadows"
any other tables of the same name in later schemas, so they won't show
in \d either.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"XML!" Exclaimed C++.  "What are you doing here? You're not a programming
language."
"Tell that to the people who use me," said XML.
https://burningbird.net/the-parable-of-the-languages/