Hacking SQL – Tools, Utilities, and Work flow.

I recently got a great suggestion from a reader over on Medium about sharing my workflow tools when hacking on SQL (mainly PostgreSQL, but sometimes MySQL also), hence here we are in this blog post.

a pile of various hand tools on a table

Photo by Fancycrave on Unsplash

As of this writing, here are the Tools/Utilities I use:

My typical work flow depends heavily on what I am doing. For one-off and ad-hoc queries, I typically use the psql command-line and its provided functionality – e.g., command history, meta-commands, Emacs-like movement and shortcuts: CTRL-B, CTRL-A, CTRL-E, etc…

When larger queries wind up active in the buffer, then I usually jump straight to Vim with the \e meta-command and work on them there. Especially if I am receiving errors or incorrect results sets.

Working with .sql source files, temp tables, CTE’s, transactions, numerous aliased table’s from mult-table joins, I lean on Sublime Text 3.
Mainly for the nice suggestions and auto-completions it gives you there (although Vim offers some too). To run individual queries from Sublime, I yank them and paste them into the \e opened Vim buffer back over in psql for execution.

For source files composed of transactions, PLpgSQL functions, multiple SQL statements, and INSERT statements with many comma-separated VALUES, I’ll just execute the file with the \i meta-command in psql.

Interested in handy psql meta-commands with example uses?
Have a look at these blog posts I have written:

Additional informative reading:

I hope this blog post has given you some ideas for tools and utilities you can incorporate into your daily SQL work flow.
Now that I’ve shared mine, I’d love to know what you use in your SQL hacking work flow, so feel free to share in the comments below.
Thanks for reading.
Be sure and visit the stellar on-line PostgreSQL 10 Documentation for any related questions.

A Call To Action!

Thank you for taking the time to read this post. I truly hope you discovered something interesting and enlightening. Please share your findings here, with someone else you know who would get the same value out of it as well.

Visit the Portfolio-Projects page to see blog post/technical writing I have completed for clients.

Have I mentioned how much I love a cup of coffee?!?!

To receive email notifications (Never spam) from this blog (“Digital Owl’s Prose”) for the latest blog posts as they are published, please subscribe (of your own volition) by clicking the ‘Click To Subscribe!’ button in the sidebar on the homepage! (Feel free at any time to review the Digital Owl’s Prose Privacy Policy Page for any questions you may have about: email updates, opt-in, opt-out, contact forms, etc…)

Be sure and visit the “Best Of” page for a collection of my best blog posts.

Josh Otwell is an open-source SQL database enthusiast with a passion to study and grow as a SQL Developer and blogger. Other favorite activities find him with his nose buried in a good book, article, or the Linux command line. Among those, he shares a love of tabletop RPG games, reading fantasy novels, and spending time with his wife and two daughters.

Disclaimer: The examples presented in this post are hypothetical ideas of how to achieve similar types of results. They are not the utmost best solution(s). The majority, if not all, of the examples provided are performed on a personal development/learning workstation-environment and should not be considered production quality or ready. Your particular goals and needs may vary. Use those practices that best benefit your needs and goals. Opinions are my own.

Hey thanks for commenting! Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.