Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs: how to set the default database type for a sql file in SQL mode

In SQL mode, we could select the product type such posgres, mysql, oracle etc, and the default one is ANSI, how to set the default type as postgresql after startup emacs? What needs to be put in .emacs?

like image 758
Daniel Wu Avatar asked Dec 30 '14 11:12

Daniel Wu


1 Answers

SQL mode has sql-set-product function which is used to set the product.

C-h f sql-set-product RET lists the details of the function.

sql-set-product is an interactive compiled Lisp function.

(sql-set-product PRODUCT)

Set `sql-product' to PRODUCT and enable appropriate highlighting.

So, you can add

(sql-set-product 'postgres)

to your .emacs file to make it as default.

At any point of time, if you want to change it mysql or something else, you can use

M-x sql-set-product RET mysql RET

Alternatively, as shown in @teaforthecat's answer, the product can be set from a comment on the first line

-- -*- mode: sql; sql-product: mysql; -*-
like image 189
Pandikunta Anand Reddy Avatar answered Oct 18 '22 22:10

Pandikunta Anand Reddy