patternsqlModerate
Is there a way to define macros/alias in psql?
Viewed 0 times
waypsqlmacrosdefinetherealias
Problem
It is somewhat annoying to type
So, is there a way to define an aliases (autocompletable ones would be very nice) in
E.g.
EXPLAIN (ANALYZE, BUFFERS, VERBOSE) in psql tool every time you tune queries.So, is there a way to define an aliases (autocompletable ones would be very nice) in
psql similar to the way it is in bash?E.g.
FULLEXPLAIN SELECT FROM pg_stat; results into EXPLAIN (ANALYZE, BUFFERS, VERBOSE) SELECT FROM pg_stat;Solution
\set fullexplain EXPLAIN (ANALYZE, BUFFERS, VERBOSE)
:fullexplain SELECT * FROM pg_stat;.Probably not the most elegant thing I admit.
Also you could put this in
.psqlrc.Code Snippets
\set fullexplain EXPLAIN (ANALYZE, BUFFERS, VERBOSE)
:fullexplain SELECT * FROM pg_stat;.Context
StackExchange Database Administrators Q#65744, answer score: 11
Revisions (0)
No revisions yet.