I want to export ONLY the sequences created in a Database created in PostgreSQL. There is any option to do that?
Thank you!
Using pg_dump CREATE TABLE foo ( id serial PRIMARY KEY, other int ); INSERT INTO foo (other) VALUES (1),(2),(3); Then dump it with pg_dump or pg_dumpall , $ pg_dump -t foo | grep -i pg_catalog. setval | grep "'public.
A sequence in PostgreSQL is a user-defined schema-bound object that generates a sequence of integers based on a specified specification. To create a sequence in PostgreSQL, you use the CREATE SEQUENCE statement.
You could write a query to generate a script that will create your existing sequence objects by querying this information schema view.
select *
from information_schema.sequences;
Something like this.
SELECT 'CREATE SEQUENCE ' || sequence_name || ' START ' || start_value || ';'
from information_schema.sequences;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With