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
COPY (SELECT * FROM sample_table) TO '/path/to/file'; | |
COPY sample_table FROM '/path/to/file'; | |
SELECT setval('sample_table_id_seq', max(id)) FROM sample_table; -- Update primary key sequence |
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
REVOKE CONNECT ON DATABASE dbname FROM PUBLIC, <username>; -- Prevent from accepting new connections | |
SELECT pg_terminate_backend(pid) | |
FROM pg_stat_activity | |
WHERE pid <> pg_backend_pid() -- Don't kill my own connection! | |
AND datname = <database>; -- Don't kill the connections to other databases |