更新时间:2025-07-10 GMT+08:00
PG_TABLES
PG_TABLES视图提供了对数据库中每个表访问的有用信息。
名称 | 类型 | 引用 | 描述 |
|---|---|---|---|
schemaname | name | PG_NAMESPACE.nspname | 包含表的模式名。 |
tablename | name | PG_CLASS.relname | 表名。 |
tableowner | name | pg_get_userbyid(PG_CLASS.relowner) | 表的所有者。 |
tablespace | name | PG_TABLESPACE.spcname | 包含表的表空间,默认为NULL。 |
hasindexes | boolean | PG_CLASS.relhasindex | 如果表上有索引(或者最近拥有)则为TRUE,否则为FALSE。 |
hasrules | boolean | PG_CLASS.relhasrules | 如果表上有规则,则为TRUE,否则为FALSE。 |
hastriggers | boolean | PG_CLASS.RELHASTRIGGERS | 如果表上有触发器,则为TRUE,否则为FALSE。 |
tablecreator | name | pg_get_userbyid(PG_OBJECT.creator) | 表创建用户,如创建用户已删除,则返回空。 |
created | timestamp with time zone | PG_OBJECT.ctime | 表创建时间。 |
last_ddl_time | timestamp with time zone | PG_OBJECT.mtime | 表最后修改时间。 |
应用示例
查询指定模式下所有的表。
1 2 3 4 5 6 7 8 9 10 11 12 13 | SELECT tablename FROM PG_TABLES WHERE schemaname = 'myschema'; tablename ---------------- inventory product sales_info test1 mytable product_info customer_info newproducts customer_t1 (9 rows) |

