PG_CLASS
PG_CLASS records database objects and their relations.
Column |
Type |
Description |
||||
---|---|---|---|---|---|---|
OID |
OID |
Row identifier (hidden attribute; must be explicitly selected) |
||||
relname |
Name |
Name of an object, such as a table, index, or view |
||||
relnamespace |
OID |
OID of the namespace that contains the relationship |
||||
reltype |
OID |
Data type that corresponds to this table's row type (the index is 0 because the index does not have pg_type record) |
||||
reloftype |
OID |
OID is of composite type. 0 indicates other types. |
||||
relowner |
OID |
Owner of the relationship |
||||
relam |
OID |
Specifies the access method used, such as B-tree and hash, if this is an index |
||||
relfilenode |
OID |
Name of the on-disk file of this relationship. If such file does not exist, the value is 0. |
||||
reltablespace |
OID |
Tablespace in which this relationship is stored. If its value is 0, the default tablespace in this database is used. This column is meaningless if the relationship has no on-disk file. |
||||
relpages |
Double precision |
Size of the on-disk representation of this table in pages (of size BLCKSZ). This is only an estimate used by the optimizer. |
||||
reltuples |
Double precision |
Number of rows in the table. This is only an estimate used by the optimizer. |
||||
relallvisible |
Integer |
Number of pages marked as all visible in the table. This column is used by the optimizer for optimizing SQL execution. It is updated by VACUUM, ANALYZE, and a few DDL statements such as CREATE INDEX. |
||||
reltoastrelid |
OID |
OID of the TOAST table associated with this table. The OID is 0 if no TOAST table exists. The TOAST table stores large columns "offline" in a secondary table. |
||||
reltoastidxid |
OID |
OID of the index for a TOAST table. The OID is 0 for a table other than a TOAST table. |
||||
reldeltarelid |
OID |
OID of a Delta table Delta tables belong to column-store tables. They store long tail data generated during data import. |
||||
reldeltaidx |
OID |
OID of the index for a Delta table |
||||
relcudescrelid |
OID |
OID of a CU description table CU description tables (Desc tables) belong to column-store tables. They control whether storage data in the HDFS table directory is visible. |
||||
relcudescidx |
OID |
OID of the index for a CU description table |
||||
relhasindex |
boolean |
Its value is true if this column is a table and has (or recently had) at least one index. It is set by CREATE INDEX but is not immediately cleared by DROP INDEX. If the VACUUM process detects that a table has no index, it clears the relhasindex column and sets the value to false. |
||||
relisshared |
boolean |
Its value is true if the table is shared across all databases in the cluster. Only certain system catalogs (such as pg_database) are shared. |
||||
relpersistence |
Char |
|
||||
relkind |
Char |
|
||||
relnatts |
Smallint |
Number of user columns in the relationship (excluding system columns) pg_attribute has the same number of rows corresponding to the user columns. |
||||
relchecks |
Smallint |
Number of constraints on a table. For details, see PG_CONSTRAINT. |
||||
relhasoids |
boolean |
Its value is true if an OID is generated for each row of the relationship. |
||||
relhaspkey |
boolean |
Its value is true if the table has (or once had) a primary key. |
||||
relhasrules |
boolean |
Its value is true if the table has rules. See table PG_REWRITE to check whether it has rules. |
||||
relhastriggers |
boolean |
Its value is true if the table has (or once had) triggers. For details, see PG_TRIGGER. |
||||
relhassubclass |
boolean |
Its value is true if the table has (or once had) any inheritance child table. |
||||
relcmprs |
tinyint |
Whether the compression feature is enabled for the table. Note that only batch insertion triggers compression so ordinary CRUD does not trigger compression.
|
||||
relhasclusterkey |
boolean |
Whether the local cluster storage is used |
||||
relrowmovement |
boolean |
Whether the row migration is allowed when the partitioned table is updated
|
||||
parttype |
Char |
Whether the table or index has the property of a partitioned table
|
||||
relfrozenxid |
xid32 |
All transaction IDs before this one have been replaced with a permanent ("frozen") transaction ID in this table. This column is used to track whether the table needs to be vacuumed in order to prevent transaction ID wraparound (or to allow pg_clog to be shrunk). The value is 0 (InvalidTransactionId) if the relationship is not a table. To ensure forward compatibility, this column is reserved. The relfrozenxid64 column is added to record the information. |
||||
relacl |
aclitem[] |
Access permissions The command output of the query is as follows:
xxxx indicates the assigned privileges, and yyyy indicates the roles that are assigned to the privileges. For details about permission descriptions, see Table 2. |
||||
reloptions |
text[] |
Access-method-specific options, as "keyword=value" strings |
||||
relfrozenxid64 |
Xid |
All transaction IDs before this one have been replaced with a permanent ("frozen") transaction ID in this table. This column is used to track whether the table needs to be vacuumed in order to prevent transaction ID wraparound (or to allow pg_clog to be shrunk). The value is 0 (InvalidTransactionId) if the relationship is not a table. |
Database object permissions are controlled using access control lists (ACLs). DWS uses aclitem to indicate the permissions on a specific database object.
- For databases and schemas, aclitem is stored in pg_database.datacl and pg_namespace.nspacl.
- For other database objects such as tables and views, aclitem is stored in pg_class.relacl.
- For column-level permissions, aclitem is stored in pg_attribute.attacl.
For example, test_user=a*r/test_user1 indicates that the test_user user has the INSERT and SELECT permissions on the current database object. The INSERT permission with WITH GRANT OPTION,means that other users can be granted the permission. /test_user1 indicates that the aclitem permission is granted by test_user1.
The following table lists all database object permissions and their abbreviations in DWS.
Permission |
Abbreviation |
Applicable Object Type |
---|---|---|
SELECT (read) |
r |
LARGE OBJECT, SEQUENCE, TABLE (and table-like objects), and table column |
UPDATE (write) |
w |
LARGE OBJECT, SEQUENCE, TABLE, and table column |
INSERT (insert) |
a |
TABLE and table column |
DELETE |
d |
TABLE |
TRUNCATE |
D |
TABLE |
REFERENCES |
x |
TABLE and table column |
TRIGGER |
t |
TABLE |
EXECUTE |
X |
FUNCTION and PROCEDURE |
USAGE |
U |
DOMAIN, FOREIGN DATA WRAPPER, FOREIGN SERVER, LANGUAGE, SCHEMA, SEQUENCE, and TYPE |
CREATE |
C |
DATABASE, SCHEMA, and TABLESPACE |
CONNECT |
c |
DATABASE |
TEMPORARY |
T |
DATABASE |
ANALYZE|ANALYSE |
A |
TABLE |
ALTER |
L |
TABLE |
DROP |
P |
TABLE |
VACUUM |
v |
TABLE |
ALL PRIVILEGES |
arwdDxtA and vLP |
TABLE |
Authorization options for preceding permissions |
* |
- |
Examples
View the OID and relfilenode of a table.
1
|
SELECT oid,relname,relfilenode FROM pg_class WHERE relname = 'table_name'; |
Count row-store tables.
1
|
SELECT 'row count:'||count(1) as point FROM pg_class WHERE relkind = 'r' and oid > 16384 and reloptions::text not like '%column%' and reloptions::text not like '%internal_mask%'; |
Count column-store tables.
1
|
SELECT 'column count:'||count(1) as point FROM pg_class WHERE relkind = 'r' and oid > 16384 and reloptions::text like '%column%'; |
Query the comments of all tables in the database.
1
|
SELECT relname as tablename,obj_description(relfilenode,'pg_class') as comment FROM pg_class; |
Query the permission of a specified table in the database.
1
|
SELECT relacl FROM pg_class WHERE relname = 'table_name'; |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot