skip to Main Content

I would like to get possibility to see inline documentation about functions and/or keywords used in SQL (PostgreSQL specifically) code. I know that I can call browser searching from inside Emacs but I would like just to read documentation inside Emacs. This is even enough for me to read info for a specific function/keyword.

2

Answers


    1. Install sql or pgsql Mode for Emacs

    Emacs comes with a built-in sql-mode that provides syntax highlighting and integration with databases, including PostgreSQL. If you want more PostgreSQL-specific features, you might consider third-party packages like pgsql mode.

    Steps:
    Enable sql-mode or pgsql-mode in Emacs when editing .sql files:
    (add-to-list ‘auto-mode-alist ‘(".sql’" . sql-mode))
    For PostgreSQL-specific customizations:
    (setq sql-postgres-program "psql") ; Use PostgreSQL client

    Login or Signup to reply.
  1. Documentation is available from the psql CLI:

    • Type h for SQL statement help.
    • ? for all help topics.

    You can run psql in sql-interactive-mode inside Emacs with M-x sql-postgres or, if you’ve set up the connection details, M-x sql-connect.


    If you connect that buffer to a sql-mode buffer, then you can issue psql commands from sql-mode as well. C-h m tells you:

    C-c C-b     sql-send-buffer
    C-c C-c     sql-send-paragraph
    C-c C-n     sql-send-line-and-next
    C-c C-r     sql-send-region
    C-c C-s     sql-send-string
    

    See also https://www.emacswiki.org/emacs/SqlQueryBuffer

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search