Updated on 2025-05-29 GMT+08:00

PG_TABLES

PG_TABLES is used to query useful information about each table in a database.

Table 1 PG_TABLES columns

Name

Type

Reference

Description

schemaname

name

PG_NAMESPACE.nspname

Name of the schema that contains a table.

tablename

name

PG_CLASS.relname

Table name

tableowner

name

pg_get_userbyid(PG_CLASS.relowner)

Table owner

tablespace

name

PG_TABLESPACE.spcname

Tablespace that contains the table. The default value is null.

hasindexes

boolean

PG_CLASS.relhasindex

The value is TRUE if the table has (or recently had) an index; otherwise, the value is FALSE.

hasrules

boolean

PG_CLASS.relhasruls

The value is TRUE if the table has rules; otherwise, the value is FALSE.

hastriggers

boolean

PG_CLASS.RELHASTRIGGERS

The value is TRUE if the table has triggers; otherwise, the value is FALSE.

tablecreator

name

pg_get_userbyid(PG_OBJECT.creator)

Table owner

created

timestamp with time zone

PG_OBJECT.ctime

Time when a table is created.

last_ddl_time

timestamp with time zone

PG_OBJECT.mtime

Time when the last DDL operation is performed on a table.