Я создал таблицу donorв схеме referenceсогласно:
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)
);
Я заполнил таблицу согласно:
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;
Когда я бегу:
\dt+ reference.*
Внутри PSQL я вижу reference.donorтаблицу:
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)
Но когда я бегу \dt+ donor*(или \dt(+)), я не вижу reference.donorтаблицу:
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)
Почему я могу видеть только reference.donorтаблицу, если я бегу \dt+ reference.*или \dt+ *.donor?
Я ожидал \dt(или \dt+), чтобы отобразить его, но это не так.
Моя search_pathвключает в себя схему referenceи пользователь postgresимеет все разрешения для схемы referenceи всех таблиц в схеме согласно:
GRANT ALL ON ALL TABLES IN SCHEMA reference TO postgres;
Просто чтобы уточнить, у меня есть две donorтаблицы, но они находятся в двух разных схемах, т. Е. oecd.donor& reference.donor. (Я вижу oecd.donorбез проблем, когда я использую \dt(+)внутри PSQL).
search_pathпервую и без того, чтобы я заранее знал имена таблиц / схем? Или я лучше из запрашиваяinformation schemaнапример ,:SELECT table_schema, table_name FROM information_schema.tables ORDER BY table_schema, table_name;?