postgresql 如何使用 SQL 查看序列详细信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38680127/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:21:08  来源:igfitidea点击:

How to view sequence details with a SQL

postgresql

提问by Sigularity

As you know, we can view the details of a sequence by using '\d' command. I would like to know if there is a way to get these information with a SQL query so that I can view the details for all sequences in PostgreSQL database.

如您所知,我们可以使用“\d”命令查看序列的详细信息。我想知道是否有办法通过 SQL 查询获取这些信息,以便我可以查看 PostgreSQL 数据库中所有序列的详细信息。

Eventually, the left 'Column' will be displayed horizontally like we see normally when we use a sql statement.

最终,左侧的“列”将像我们在使用 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

采纳答案by Gordon Linoff

If I understand correctly, you can use `INFORMATION_SCHEMA.sequences.

如果我理解正确,您可以使用`INFORMATION_SCHEMA.sequences。

There documentation is here.

有文档here

回答by allkenang

To view the DDL of the sequence, use this

要查看序列的 DDL,请使用此

select * from information_schema.sequences where sequence_name='<your_sequence_name_in_lower_case>'