Advertisement
asanchez75

postgres/multiline

Mar 13th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. https://serverfault.com/questions/415323/whats-a-convenient-way-to-execut-multiline-queries-in-postgres-using-ssh
  2. Query buffer!
  3.  
  4. $ psql <your database name>
  5. Will take you to postgres's interactive terminal
  6.  
  7. # \e
  8. for 'edit' will open up a query buffer. Write some query, like
  9.  
  10. select now();
  11. within vim, nano, or whatever text editor you use. You're now in your favorite command-line text editor, and have all the multi-line capability you want.
  12.  
  13. Save and quit your editor, and psql will run the query you just wrote.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement