I have created the table donor
in the schema reference
as per:
CREATE TABLE reference.donor (
donor_code smallint PRIMARY KEY,
donor_name character varying NOT NULL,
donor_type smallint REFERENCES reference.donor_type (type_id),
alpha_2_code char(2) REFERENCES reference.iso_3166_1 (alpha_2_code)
);
I have populated the table as per:
INSERT INTO reference.donor (donor_code, donor_name, donor_type, alpha_2_code)
SELECT donor_code, donor_name, donor_type, alpha_2_code
FROM reference.donor_template;
When I run:
\dt+ reference.*
inside psql I see the reference.donor
table:
List of relations
Schema | Name | Type | Owner | Size | Description
-----------+----------------+-------+----------+-------+-------------
reference | donor | table | postgres | 16 kB |
reference | donor_template | table | postgres | 16 kB |
reference | donor_type | table | postgres | 16 kB |
reference | iso_3166_1 | table | postgres | 48 kB |
(4 rows)
But when I run \dt+ donor*
(or \dt(+)
) I don't see the reference.donor
table:
List of relations
Schema | Name | Type | Owner | Size | Description
-----------+----------------+-------+----------+-------+-------------
oecd_cl | donor | table | postgres | 16 kB |
reference | donor_template | table | postgres | 16 kB |
reference | donor_type | table | postgres | 16 kB |
(3 rows)
Why can I only see the reference.donor
table if I run \dt+ reference.*
or \dt+ *.donor
?
I was expecting \dt
(or \dt+
) to display it, but it does not.
My search_path
includes the schema reference
& the user postgres
has all permissions on the schema reference
and all tables in the schema as per:
GRANT ALL ON ALL TABLES IN SCHEMA reference TO postgres;
Just to clarify, I have two donor
tables, but they are in two different schemas i.e., oecd.donor
& reference.donor
. (I can see oecd.donor
without any problems when I use \dt(+)
inside psql).
Best Answer
The documentation on psql explains:
Bold emphasis mine.
Obviously, you have
oecd_cl
beforereference
in your search path. Use this for your purpose:And you'll get: