How to Show the Current Setting for Null Output in PostgreSQL (psql)

When using psql, null values are returned as an empty string by default.

This can easily be changed with the \pset command, so it could be a value other than the default empty string.

If you’re not sure what your current value is, you can use the show \pset null command to show the current value.

Example

Here’s an example to demonstrate:

show \pset null

Here’s what it looks like when it’s set to the default value:

Null display is "".

This tells me that whenever a query returns a null value, an empty string will be returned for that value:

SELECT null AS Result;

Here’s what it looks like when it’s set to the default value:

 result 
--------
 
(1 row)

You can always use /pset null '<value>' to change this value to avoid mistaking a null value for an actual empty string.