如您所知,我们可以使用“\d”命令查看序列的详细信息。我想知道是否有办法通过 SQL 查询获取这些信息,以便我可以查看 PostgreSQL 数据库中所有序列的详细信息。
最终,左侧的“列”将像我们在使用 sql 语句时通常看到的那样水平显示。
postgres=# \d next_empno
Sequence "public.next_empno"
Column | Type | Value
---------------+---------+---------------------
sequence_name | name | next_empno
last_value | bigint | 8000
start_value | bigint | 8000
increment_by | bigint | 1
max_value | bigint | 9223372036854775807
min_value | bigint | 1
cache_value | bigint | 1
log_cnt | bigint | 0
is_cycled | boolean | f
is_called | boolean | f
Run Code Online (Sandbox Code Playgroud)
小智 8
要查看序列的 DDL,请使用此
select * from information_schema.sequences where sequence_name='<your_sequence_name_in_lower_case>'
Run Code Online (Sandbox Code Playgroud)