8

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?

Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
Daniel Wu
  • 5,853
  • 12
  • 42
  • 93

3 Answers3

12

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; -*-
Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
5

This is also an option, a comment on the first line in a file.

-- -*- mode: sql; sql-product: mysql; -*-

See http://stackoverflow.com/a/18118619/714357

Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
teaforthecat
  • 4,813
  • 2
  • 16
  • 8
2

How to set the default type as postgresql after startup emacs?
What needs to be put in .emacs?

All you need is:

(setq sql-product 'postgres)

n.b. This approach does not necessitate that sql.el already be loaded.

phils
  • 71,335
  • 11
  • 153
  • 198