Reputation: 967
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.
Eventually, the left 'Column' will be displayed horizontally like we see normally when we use a sql statement.
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
Upvotes: 12
Views: 32584
Reputation: 170
SQL for view 'sequences':
SELECT * FROM information_schema.sequences
Upvotes: 0
Reputation: 1645
To view the DDL of the sequence, use this
select * from information_schema.sequences where sequence_name='<your_sequence_name_in_lower_case>'
Upvotes: 13
Reputation: 1270553
If I understand correctly, you can use `INFORMATION_SCHEMA.sequences.
There documentation is here.
Upvotes: 8