Skip to content

ybsql Startup File

Startup files are useful for preserving settings and shortcuts that users want to enable every time they log into ybsql. You can use the YBSQLRC environment variable to set the location of startup files for users.

When you start up ybsql, the startup file is read automatically. For example, here the NULL display and expanded display settings are both in effect:

$ ybsql premdb
Null display is "[NULL]".
Expanded display is used automatically.
ybsql (5.0.0)
Type:  \h for help with SQL commands
      \? for help with ybsql commands
      \g or terminate with semicolon to execute query
      \q to quit
premdb=#

To start a session without reading the startup file, use the -X option. For example:

$ ybsql premdb -X
ybsql (5.0.0)
Type:  \h for help with SQL commands
      \? for help with ybsql commands
      \g or terminate with semicolon to execute query
      \q to quit
premdb=#

.ybsqlrc File on Linux

You can create a .ybsqlrc startup file in the client user's home directory. For example, the file could have contents like this:

user1@user1:~$ more .ybsqlrc
-- By default, NULL displays as an empty space. Is it actually an empty
-- string, or is it null? This makes that distinction visible.
\pset null '[NULL]'
-- Use table format (with headers across the top) by default, but switch to
-- expanded table format when there's a lot of data, which makes it much
-- easier to read.
\x auto
...

ybsqlrc.conf File on Windows

On Windows clients, the ybsqlrc.conf file must be under the default PostgreSQL directory for the user:

%APPDATA%\postgresql

If this directory does not exist, users can create it as follows:

mkdir %APPDATA%\postgresql

This command creates a directory like this:

C:\Users\your_username\AppData\Roaming\postgresql\

The psqlrc.conf file is not recognized, even if it exists.

Parent topic:ybsql Reference