pg_sequences

一个提供有关序列的人类可读信息的系统视图

pg_sequences 是一个提供有关序列的人类可读信息的系统目录视图。它基于底层的系统目录pg_sequence

pg_sequencesPostgreSQL 10中引入。

注释

某些 pg_sequences 返回的列名与在序列关系中包含的列名匹配,该关系早于PostgreSQL 10。有关更多信息,请参阅pg_sequence

按 PostgreSQL 版本定义

pg_sequences (PostgreSQL 17)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default 
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          | 
 sequencename  | name    |           |          | 
 sequenceowner | name    |           |          | 
 data_type     | regtype |           |          | 
 start_value   | bigint  |           |          | 
 min_value     | bigint  |           |          | 
 max_value     | bigint  |           |          | 
 increment_by  | bigint  |           |          | 
 cycle         | boolean |           |          | 
 cache_size    | bigint  |           |          | 
 last_value    | bigint  |           |          |
    

文档: pg_sequences

pg_sequences (PostgreSQL 16)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default 
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          | 
 sequencename  | name    |           |          | 
 sequenceowner | name    |           |          | 
 data_type     | regtype |           |          | 
 start_value   | bigint  |           |          | 
 min_value     | bigint  |           |          | 
 max_value     | bigint  |           |          | 
 increment_by  | bigint  |           |          | 
 cycle         | boolean |           |          | 
 cache_size    | bigint  |           |          | 
 last_value    | bigint  |           |          |
    

文档: pg_sequences

pg_sequences (PostgreSQL 15)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default 
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          | 
 sequencename  | name    |           |          | 
 sequenceowner | name    |           |          | 
 data_type     | regtype |           |          | 
 start_value   | bigint  |           |          | 
 min_value     | bigint  |           |          | 
 max_value     | bigint  |           |          | 
 increment_by  | bigint  |           |          | 
 cycle         | boolean |           |          | 
 cache_size    | bigint  |           |          | 
 last_value    | bigint  |           |          |
    

文档: pg_sequences

pg_sequences (PostgreSQL 14)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default 
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          | 
 sequencename  | name    |           |          | 
 sequenceowner | name    |           |          | 
 data_type     | regtype |           |          | 
 start_value   | bigint  |           |          | 
 min_value     | bigint  |           |          | 
 max_value     | bigint  |           |          | 
 increment_by  | bigint  |           |          | 
 cycle         | boolean |           |          | 
 cache_size    | bigint  |           |          | 
 last_value    | bigint  |           |          |
    

文档: pg_sequences

pg_sequences (PostgreSQL 13)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default 
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          | 
 sequencename  | name    |           |          | 
 sequenceowner | name    |           |          | 
 data_type     | regtype |           |          | 
 start_value   | bigint  |           |          | 
 min_value     | bigint  |           |          | 
 max_value     | bigint  |           |          | 
 increment_by  | bigint  |           |          | 
 cycle         | boolean |           |          | 
 cache_size    | bigint  |           |          | 
 last_value    | bigint  |           |          |
    

文档: pg_sequences

pg_sequences (PostgreSQL 12)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default 
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          | 
 sequencename  | name    |           |          | 
 sequenceowner | name    |           |          | 
 data_type     | regtype |           |          | 
 start_value   | bigint  |           |          | 
 min_value     | bigint  |           |          | 
 max_value     | bigint  |           |          | 
 increment_by  | bigint  |           |          | 
 cycle         | boolean |           |          | 
 cache_size    | bigint  |           |          | 
 last_value    | bigint  |           |          |
    

文档: pg_sequences

pg_sequences (PostgreSQL 11)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default 
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          | 
 sequencename  | name    |           |          | 
 sequenceowner | name    |           |          | 
 data_type     | regtype |           |          | 
 start_value   | bigint  |           |          | 
 min_value     | bigint  |           |          | 
 max_value     | bigint  |           |          | 
 increment_by  | bigint  |           |          | 
 cycle         | boolean |           |          | 
 cache_size    | bigint  |           |          | 
 last_value    | bigint  |           |          |
    

文档: pg_sequences

pg_sequences (PostgreSQL 10)

              View "pg_catalog.pg_sequences"
    Column     |  Type   | Collation | Nullable | Default 
---------------+---------+-----------+----------+---------
 schemaname    | name    |           |          | 
 sequencename  | name    |           |          | 
 sequenceowner | name    |           |          | 
 data_type     | regtype |           |          | 
 start_value   | bigint  |           |          | 
 min_value     | bigint  |           |          | 
 max_value     | bigint  |           |          | 
 increment_by  | bigint  |           |          | 
 cycle         | boolean |           |          | 
 cache_size    | bigint  |           |          | 
 last_value    | bigint  |           |          |
    

文档: pg_sequences

更改历史记录

自它在PostgreSQL 10中添加以来,此视图没有进行修改。

示例

postgres=# CREATE SEQUENCE foo_seq;
CREATE SEQUENCE

postgres=# SELECT * FROM pg_sequences WHERE sequencename='foo_seq';
-[ RECORD 1 ]-+--------------------
schemaname    | public
sequencename  | foo_seq
sequenceowner | postgres
data_type     | bigint
start_value   | 1
min_value     | 1
max_value     | 9223372036854775807
increment_by  | 1
cycle         | f
cache_size    | 1
last_value    | 

分类

DDL序列系统目录

另请参阅

pg_sequenceCREATE SEQUENCEpg_get_serial_sequence()

反馈

提交任何关于 "pg_sequences" 的评论、建议或更正 此处