Maintain a History of YSQL Commands

ysqlsh is a shell for interacting with the YugabyteDB YSQL API.

By default, the commands that you type are kept in a history file, but only for the current session and all databases.

If you’d like to maintain the separate command history for each of your databases and have it avaiable the next time you launch ysqlsh, you can set the HISTFILE variable to the file name used to store the history list. 

The default file which stores command history is ~/.psql_history.

So, by putting the following command:

				
					\set HISTFILE ~/.psql_history- :DBNAME
				
			

in ~/.psqlrc causes ysqlsh to maintain a separate history for each database.

Have Fun!