Send the current paragraph to the SQL process with \"explain \" keyword.
Works at least for MySql/MariaDB.
--- a/.emacs-my Sat Jan 09 23:19:24 2016 +0200
+++ b/.emacs-my Sat Jan 23 21:08:36 2016 +0200
@@ -3095,6 +3095,20 @@
(add-hook 'sql-interactive-mode-hook (lambda () (toggle-truncate-lines 1)))
+(defun my-sql-explain-paragraph ()
+ "Send the current paragraph to the SQL process with \"explain \" keyword.
+Works at least for MySql/MariaDB."
+ (interactive)
+ (let ((start (save-excursion
+ (backward-paragraph)
+ (point)))
+ (end (save-excursion
+ (forward-paragraph)
+ (point))))
+ (sql-send-string (concat "explain " (buffer-substring-no-properties start end)))))
+(eval-after-load 'sql-mode
+ (define-key sql-mode-map (kbd "C-c C-e") 'my-sql-explain-paragraph))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "backuping")