You can also combine this with TRAMP to work on databases you can't directly access from your local machine. E.g.:
#+header: :dir /ssh:user@remote-host:/ #+begin_src sql .. #+end_src