Created
March 23, 2022 08:05
-
-
Save redsfyre/2c3c0cc199bac456673f28d461f41aa1 to your computer and use it in GitHub Desktop.
List postgresql sequences. Actually i dont remember what is this query :D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select sequence_name, (xpath('/row/last_value/text()', xml_count))[1]::text::int as last_value | |
from ( | |
select sequence_schema, | |
sequence_name, | |
query_to_xml(format('select last_value from %I.%I', sequence_schema, sequence_name), false, true, '') as xml_count | |
from information_schema.sequences | |
where sequence_schema = 'public' | |
) new_table order by sequence_name asc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment