2

I ran this query on a PostgreSQL table:

select * wkt from table  where column <>'' and  column is not null

..and unexpectedly received several rows with no visible value in that column. Why is this? Is there some 'hidden' value in that column for those rows, or a corrupted table, or something else?

3
  • 1
    i belive many value will be invisible, eg ascii 0,1,2,3,4,5,6,7, depends on client though
    – Vao Tsun
    Commented Jan 25, 2018 at 16:30
  • 1
    Or just spaces. Commented Jan 25, 2018 at 16:30
  • you check the first char with ascii function
    – Vao Tsun
    Commented Jan 25, 2018 at 16:34

1 Answer 1

5
t=# select ascii(chr(9));
 ascii
-------
     9
(1 row)

thus

select ascii(column) from table  where column <>'' and  column is not null

should give the idea

https://www.postgresql.org/docs/current/static/functions-string.html

ASCII code of the first character of the argument. For UTF8 returns the Unicode code point of the character. For other multibyte encodings, the argument must be an ASCII character.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.