Here's my next installment of "GNU Emacs as a lightweight IDE" series for editing SQL. These enhancements to Semantic and sql-mode allows SQL code-completion for most common use-cases.
Offline - Use DDLs in current file for auto-suggest
Online - Use table information from DB for auto-suggest. DB connection is made using JDBC which allows connection to ANY DB in a platform independent manner. It also allows multiple simultaneous connections with easy switch-over.
Hope this will aid your productivity while using SQL in Emacs.
;; Install company for inline completion with dropdown
The SQL specific implementation is confined to three files - sql.wy, sql.el and company-semantic.el. Most of the heavy lifting is done by the semantic and company framework.
- sql.wy - This is the language grammar file. You compile this (run make in emacs/lisp directory) to generate language parser sql-tags-wy.el.
- semantic/sql.el - Overrides some semantic functions
- company-semantic.el - Deals with auto-completion using semantic
- progmodes/sql.el - JDBC product definition and supporting functions
- H2 web console supports "@tables" meta commands. My customization makes them available to CLI console as well.