What does regclass signify in Postgresql

后端 未结 2 1195
旧巷少年郎
旧巷少年郎 2021-01-31 07:37

I have the following line in a CREATE TABLE statement:

field1_id bigint DEFAULT nextval(\'table1_field1_id_seq\'::regclass) NOT NULL,

What does

2条回答
  •  后悔当初
    2021-01-31 08:43

    From what I understand of the documentation, oid are subdivided in types. regclass are database objects representing relations (so that they belong to the metadata table pg_class).

    It expresses a dependency between the sequence and the DEFAULT expression (meaning the process of producing a default value if no explicit value is provided in a INSERT query for instance), so that if one emits a DROP SEQUENCE ... on the sequence, the query won't pass, unless it's cascaded (by writing DROP SEQUENCE table1_field1_id_seq CASCADE).

提交回复
热议问题