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 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 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.