pgAdmin 中的临时表

发布于 2024-10-30 03:17:36 字数 160 浏览 3 评论 0原文

我在 Postgres 8.4 数据库中使用 pgAdmin,我想知道在哪里(任何表/架构/等?)可以找到当前使用的临时表的列表?我想一定有一个地方可以找到它。

它们不存在于目录对象中,也不存在于视图中,还有其他建议吗?

I am using pgAdmin for my Postgres 8.4 database and I was wondering where (any table/schema/etc. ?) may I find a list of currently used temporary tables? I assume there has to be a place where I can find it.

They are not present in a catalog object tables nor in views, any other suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

尸血腥色 2024-11-06 03:17:36

临时表存在于临时模式 pg_temp_{№} 中,默认情况下隐藏在 pgAdmin UI 中。

在 pgAdmin(至少 pgAdmin4)中,您可以打开首选项窗格并打开此设置:

显示 -> 显示系统对象?True

这将显示您创建的隐藏架构临时表。

PS 更改首选项后刷新架构树

Temporary tables live in temporary schemas pg_temp_{№} that hidden by default in pgAdmin UI.

In pgAdmin(pgAdmin4 at least) you can open preferences pane and switch on this setting:

Display->Show system objects? to True

This will show hidden schemas with your created temp tables.

PS After changing preference refresh schema tree

感情废物 2024-11-06 03:17:36

Postgres 为名为“pg_temp_#”的临时表创建一个临时模式,您可以使用 psql 查看它...

create temp table mytemptable(name varchar);

select c.relname
from pg_namespace n
  join pg_class   c on n.oid=c.relnamespace
where n.nspname='pg_temp_1';

您可以列出在 psql 中执行“\dn”的模式。

希望有帮助。

Postgres creates a temporary schema for temporary tables named "pg_temp_#", you can see it with psql...

create temp table mytemptable(name varchar);

select c.relname
from pg_namespace n
  join pg_class   c on n.oid=c.relnamespace
where n.nspname='pg_temp_1';

You can list your schemas executing "\dn" in psql.

Hope that helps.

时常饿 2024-11-06 03:17:36

在 pgAdmin 4 中你只需要启用

属性->浏览器->显示->显示系统对象

(从底部开始第一个)。之后你就可以在里面找到你的桌子了

pg_temp_(#) 架构

In pgAdmin 4 you just need to enable in

Properties -> Browser -> Display -> Show system objects

(this one first from the bottom). After this you would be able to find your table inside

pg_temp_(#) schema

爱的那么颓废 2024-11-06 03:17:36

https://www.dbrnd.com/2017/06/postgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection /

SELECT
    n.nspname as SchemaName
    ,c.relname as RelationName
    ,CASE c.relkind
    WHEN 'r' THEN 'table'
    WHEN 'v' THEN 'view'
    WHEN 'i' THEN 'index'
    WHEN 'S' THEN 'sequence'
    WHEN 's' THEN 'special'
    END as RelationType
    ,pg_catalog.pg_get_userbyid(c.relowner) as RelationOwner               
    ,pg_size_pretty(pg_relation_size(n.nspname ||'.'|| c.relname)) as RelationSize
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n               
                ON n.oid = c.relnamespace
WHERE  c.relkind IN ('r','s') 
AND  (n.nspname !~ '^pg_toast' and nspname like 'pg_temp%')
ORDER BY pg_relation_size(n.nspname ||'.'|| c.relname) DESC

将显示所有临时表的输出。

 schemaname | relationname | relationtype | relationowner | relationsize
------------+--------------+--------------+---------------+--------------
 pg_temp_63 | temp_sl_4    | table        | power_bi_cr   | 2355 MB
 pg_temp_63 | temp_sl_3    | table        | power_bi_cr   | 1342 MB
 pg_temp_63 | temp_sl_2    | table        | power_bi_cr   | 1239 MB
 pg_temp_63 | temp_sl      | table        | power_bi_cr   | 1216 MB
 pg_temp_63 | temp_sl_gr   | table        | power_bi_cr   | 521 MB
 pg_temp_63 | temp_ftlo    | table        | power_bi_cr   | 457 MB
 pg_temp_63 | temp_th3     | table        | power_bi_cr   | 123 MB
 pg_temp_63 | temp_th      | table        | power_bi_cr   | 79 MB
 pg_temp_63 | temp_th2     | table        | power_bi_cr   | 17 MB
(9 rows)

https://www.dbrnd.com/2017/06/postgresql-find-a-list-of-active-temp-tables-with-size-and-user-information-idle-connection/

SELECT
    n.nspname as SchemaName
    ,c.relname as RelationName
    ,CASE c.relkind
    WHEN 'r' THEN 'table'
    WHEN 'v' THEN 'view'
    WHEN 'i' THEN 'index'
    WHEN 'S' THEN 'sequence'
    WHEN 's' THEN 'special'
    END as RelationType
    ,pg_catalog.pg_get_userbyid(c.relowner) as RelationOwner               
    ,pg_size_pretty(pg_relation_size(n.nspname ||'.'|| c.relname)) as RelationSize
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n               
                ON n.oid = c.relnamespace
WHERE  c.relkind IN ('r','s') 
AND  (n.nspname !~ '^pg_toast' and nspname like 'pg_temp%')
ORDER BY pg_relation_size(n.nspname ||'.'|| c.relname) DESC

Will show you output of all temporary tables.

 schemaname | relationname | relationtype | relationowner | relationsize
------------+--------------+--------------+---------------+--------------
 pg_temp_63 | temp_sl_4    | table        | power_bi_cr   | 2355 MB
 pg_temp_63 | temp_sl_3    | table        | power_bi_cr   | 1342 MB
 pg_temp_63 | temp_sl_2    | table        | power_bi_cr   | 1239 MB
 pg_temp_63 | temp_sl      | table        | power_bi_cr   | 1216 MB
 pg_temp_63 | temp_sl_gr   | table        | power_bi_cr   | 521 MB
 pg_temp_63 | temp_ftlo    | table        | power_bi_cr   | 457 MB
 pg_temp_63 | temp_th3     | table        | power_bi_cr   | 123 MB
 pg_temp_63 | temp_th      | table        | power_bi_cr   | 79 MB
 pg_temp_63 | temp_th2     | table        | power_bi_cr   | 17 MB
(9 rows)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文