Skip to content

Instantly share code, notes, and snippets.

@malko
Created May 5, 2022 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malko/b455030fa408ba9369fd74a704a16f4a to your computer and use it in GitHub Desktop.
Save malko/b455030fa408ba9369fd74a704a16f4a to your computer and use it in GitHub Desktop.
Psql imports useful commands
-- deactivates all triggers and constraints
SET session_replication_role = replica;
-- restore triggers and constraints
SET session_replication_role = DEFAULT;
-- treat out-of-sync auto-increment sequence fields (use double quote arround table names to preserve uppercase letters)
SELECT pg_catalog.setval(pg_get_serial_sequence('"table_name"', 'id'), MAX(id)) FROM "table_name";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment