Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show leading/trailing whitespace in a PostgreSQL column?

I can't see leading/trailing whitespace in the following following SQL statement executed with psql:

select name from my_table;

Is there a pragmatic way to see leading/trailing whitespace?

like image 724
guettli Avatar asked Jan 11 '16 08:01

guettli


1 Answers

One of option is to use format() function.

With given query case: select format( '"%s"', name ) from my_table;

PoC:

SELECT  format( '"%s"', name )
FROM    ( VALUES ( ' a ' ), ( ' b ' ) ) v(name);

 format
--------
 " a "
 " b "
(2 rows)
like image 55
Kristo Mägi Avatar answered Sep 21 '22 19:09

Kristo Mägi