问题
In the psql documentation, I read information about variables (section advanced features), e.g. one of these variables is:
HISTSIZE
The number of commands to store in the command history. The default value is 500.
Is there a file in the home directory or somewhere else where I can configure these variables?
What syntax would I use in that file?
回答1:
If you look at the Files section, you'll see this:
Files
Unless it is passed an
-Xor-coption, psql attempts to read and execute commands from the system-widepsqlrcfile and the user's~/.psqlrcfile before starting up. (On Windows, the user's startup file is named%APPDATA%\postgresql\psqlrc.conf.) SeePREFIX/share/psqlrc.samplefor information on setting up the system-wide file. It could be used to set up the client or the server to taste (using the\setandSETcommands).The location of the user's
~/.psqlrcfile can also be set explicitly via thePSQLRCenvironment setting.
So like most Unix commands, there is an RC ("Run Commands") file that you can use for configuration, the name also matches the Unix conventions of ~/.cmdrc so you want ~/.psqlrc.
The format matches the \set commands you'd use within psql itself:
\set HISTSIZE 11
for example.
来源:https://stackoverflow.com/questions/21518898/psql-init-files