postgresql-system tables, System views

Source: Internet
Author: User
Tags postgresql

The system tables show the information under the current operations database, and the objects are from the current database. Because different system tables use different name fields to record the OID of different objects, the table references that table, and the table references another table, so these field names are not very good to remember.

  Pg_class (System table: Object) is an object table , each field of the table is ' rel ' beginning, clearly is 'relation ' the word abbreviation, meaning ' relationship '. the Relkind field in the table determines the object type: R = Normal table, i = index, s = sequence, V = view, c = Compound type, S = special, T = Toast table. the Relnamespace (schema name) and Relowner (owner) that the object belongs to are displayed with its corresponding OID, so it is intuitive to see the actual name to be federated pg_namespace (System table: Schema) and Pg_ Roles (System view: Role) , both tables and views have OID fields.

Take the query object's owning pattern and its name as an example:

SelectRelname,relkind,relnamespace,nspname fromPg_class c,pg_namespace NwhereN.oid=16424  andC.relnamespace=n.oid Relname|Relkind|Relnamespace|Nspname-------------------+---------+--------------+---------Website_pkey|I|        16424 |Yun website|R|        16424 |Yun Board_pkey|I|        16424 |Yun Board|R|        16424 |Yun Spam_keyword_pkey|I|        16424 |Yun Spam_keyword|R|        16424 |Yun

OID data type, the query can have no single quotation mark. The OID field in Pg_namespace is implied and cannot be queried directly with SELECT * from.

SelectOid*  fromPg_namespace

OID | Nspname |               Nspowner | Nspacl
-------+--------------------+----------+-------------------------------------
99 |       Pg_toast | 10 |
11194 |       Pg_temp_1 | 10 |
11195 |       Pg_toast_temp_1 | 10 |
11 |       Pg_catalog | 10 | {Postgres=uc/postgres,=u/postgres}
11469 |       Information_schema | 10 | {Postgres=uc/postgres,=u/postgres}
2200 |       Public | 10 | {Postgres=uc/postgres,=uc/postgres}
16424 |    Yun | 16392 |
16551 |    Audit | 16392 |

PS: A comma is actually a symbol that acts as a link between several columns and columns, and is a symbol that directly affects the results of the query, not because multiple fields are checked so that it is easy to read and look good.

Pg_namespace has a oid,pg_roles of the user's OID.

Pg_attribute, there is such a table to record all the fields of the table, magical.

postgresql-system tables, System views

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.