小编sai*_*utz的帖子

PostgreSQL\_dt命令不会在search_path模式中显示*ALL*表

为什么在PostgreSQL中,当不同模式中存在同名的表时,\dt只包含搜索路径中列出的第一个模式中的表,如下例所示?

我对......感兴趣:

  1. 这是理想的原因,并且

  2. 在查询基础的情况下如何实现它\dt(见下文).

(顺便说一下,我从这个答案中意识到\dt *.*将列出每个模式中的每个表 - 但是对于下面的示例情况,这给了我58个系统表,除了我做的两个之外我不想要它!)


dt_test=# CREATE SCHEMA first;
CREATE SCHEMA
dt_test=# CREATE SCHEMA second;
CREATE SCHEMA
dt_test=# CREATE TABLE first.my_table(id integer);
CREATE TABLE
dt_test=# CREATE TABLE second.my_table(id integer);
CREATE TABLE
dt_test=# set search_path to first,second;
SET
dt_test=# \dt
         List of relations
 Schema |   Name   | Type  | Owner  
--------+----------+-------+--------
 first  | my_table | table | postgres
(1 row)

dt_test=# set search_path to second,first;
SET
dt_test=# \dt
         List …
Run Code Online (Sandbox Code Playgroud)

postgresql search-path

7
推荐指数
1
解决办法
2860
查看次数

标签 统计

postgresql ×1

search-path ×1