Last active
August 28, 2017 10:59
-
-
Save johanek/6447285 to your computer and use it in GitHub Desktop.
Useful postgres commands
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
Example of getting size of fields: | |
SELECT id, length(raw), length(cooked) FROM posts ORDER BY length(cooked) DESC limit 100; | |
Truncate table: | |
truncate table <table>; | |
Show size of tables: | |
\dt+ | |
Terminate all connections to a DB: | |
SELECT pg_terminate_backend(pg_stat_activity.pid) | |
FROM pg_stat_activity | |
WHERE pg_stat_activity.datname = 'TARGET_DB'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment