PostgreSQL - empty values that are not null and not empty strings

11,431
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.

Share:
11,431

Related videos on Youtube

JasonBK
Author by

JasonBK

Updated on June 04, 2022

Comments

  • JasonBK
    JasonBK almost 2 years

    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?

    • Vao Tsun
      Vao Tsun over 6 years
      i belive many value will be invisible, eg ascii 0,1,2,3,4,5,6,7, depends on client though
    • dani herrera
      dani herrera over 6 years
      Or just spaces.
    • Vao Tsun
      Vao Tsun over 6 years
      you check the first char with ascii function