PostgreSQL Chinese Learning Manual (system table)

Source: Internet
Author: User

I. pg_class:

The system table records metadata of data tables, indexes (still need to see pg_index), sequences, views, composite types, and some special link types. Note: not all fields make sense for all object types.

Name Type Reference Description
Relname Name   Data Type name.
Relnamespace Oid Pg_namespace.oid OI that contains the namespace (mode) of this object.
Reltype Oid Pg_type.oid The data type corresponding to the row type of this table.
Relowner Oid Pg_authid.oid The owner of the object.
Relam Oid Pg_am.oid The index object indicates the index type (B-tree, hash ).
Relfilenode Oid   The name of the file where the object is stored on the disk. If not, it is 0.
Reltablespace Oid Pg_tablespace.oid The tablespace where the object is located. If the value is zero, the default tablespace of the database is used. (This field makes no sense if the object has no files on the disk)
Relpages Int4   The number of disk pages occupied by the data table or index. The query planner selects the optimal path with this value.
Reltuples Float4   The number of rows in the table. This value is only an estimate used by the scheduler.
Reltoastrelid Oid Pg_class.oid OID of the TOAST table associated with this table, if not 0. The TOAST table stores large fields offline in a subordinate table.
Reltoastidxid Oid Pg_class.oid If it is a TOAST table, this field is the OID of its index, and if it is not a TOAST table, it is 0.
Relhasindex Bool   If this is a data table with at least (or recently) One index, it is true. It is set by create index, but drop index does not immediately clear it. If VACUUM finds that a table has no index, it clears relhasindex.
Relisshared Bool   True if the table is shared by all databases in the cluster.
Relkind Char   R = normal table, I = index, S = sequence, v = view, c = composite type, s = Special, t = TOAST table
Relnatts Int2   Number of user fields in the data table (excluding system fields, such as oid ). The pg_attribute is bound to have the same number of data rows. See pg_attribute.attnum.
Relchecks Int2   Check the number of constraints in the table. For more information, see pg_constraint.
Reltriggers Int2   Number of triggers in the table. For more information, see pg_trigger.
Relhasoids Bool   If we generate an OID for each row of the object, it is true.
Relhaspkey Bool   If the table has a primary key, it is true.
Relhasrules Bool   If the table has rules, it will be true. SeePg_rewriteTable.
Relhassubclass Bool    If the table has a sub-table, it is true.
Relacl Aclitem []   Access permission.

See the following application example:
# View the mode of the specified table object testtable
Postgres = # SELECT relname, relnamespace, nspname FROM pg_class c, pg_namespace n WHERE relname = 'testtable' AND relnamespace = n. oid;
Relname | relnamespace | nspname
------------- + -------------- + ---------
Testtable | 2200 | public
(1 row)
# View the owner (role) of the specified table object testtable ).
Postgres = # select relname, rolname from pg_class c, pg_authid au where relname = 'testtable' and relowner = au. oid;
Relname | rolname
------------- + ----------
Testtable | postgres
(1 row)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.