Postgres:是否有查询返回给定用户拥有的表? [英] Postgres: Is there a query to return the tables owned by a given user?

查看:145
本文介绍了Postgres:是否有查询返回给定用户拥有的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个查询(不是\dn或\dt之类的命令,因为我没有从命令行运行该命令),它将让我指定用户名,并获取与该用户关联的所有表(以及理想情况下,它正在使用多少磁盘空间以及其他详细信息。)

I need a query (not a command like \dn or \dt or whatnot as I am not running this from the command line) that will let me specify a username, and get all of the tables associated with that user (and ideally how much disk space it is using and other details).

是否存在这样的命令?非常感谢。

Does such a command exist? Thank you very much.

推荐答案

您可以在目录。目录是表的集合,其中包含有关正在运行的Postgres实例的元数据。因此,使用SQL进行查询很容易。要查找特定用户拥有的所有表,可以查询 pg_tables 。对于尺寸,您可能必须加入 pg_class

You can look up such information in the catalog. The catalog is a collection of tables containing meta data about a running Postgres instance. Therefore it is easy to query with SQL. To find all tables owned by a particular user you can query pg_tables. For sizes you probably have to join pg_class.

这篇关于Postgres:是否有查询返回给定用户拥有的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆