In emacs (in whatever mode you recommend for accessing a Postgres database)
is it possible to type
select * from foo_<tab>
and somehow get autocomplete/help as to what tables are available in the database
( tables that start with foo_
)
I would also like (yasnippet?) help writing long sql. eg.
select name from users where email='abc@def.com' order by name limit 200;
I guess I will have to learn yasnippet for that.
yasnippet
. You'd need to write anauto-complete
orcompany
plugin. However, doing smart completion would be a challenging task, since you also need to understand (programmatically) the SQL statement, and figure out whether it is a place where table name is allowed (or maybe a table field name), and then figure out if field name must be qualified with table name, is the table accessible to the user who will be running the query, is it aliased etc.\d
in theSQLi
buffer runningpsql
, so that postgres outputs all the table names, thendabbrev-expand
would be able to see and complete them.