Delete empty rows

前端 未结 4 1540
盖世英雄少女心
盖世英雄少女心 2021-02-01 17:45

I use PostgreSQL database and in one table I have the datetime column edit_user. Some rows are blank, and these rows I would like to delete.

I tried

4条回答
  •  礼貌的吻别
    2021-02-01 18:25

    If you are trying to delete empty spaces , try using ='' instead of is null. Hence , if your row contains empty spaces , is null will not capture those records. Empty space is not null and null is not empty space.

    Dec  Hex     Binary    Char-acter Description
    0    00  00000000      NUL        null
    
    32  20  00100000      Space       space
    

    So I recommend:

    delete  from foo_table  where bar = ''
    
    #or 
    
    delete  from foo_table  where bar = '' or bar is null 
    
    #or even better , 
    
    delete from foo_table where rtrim(ltrim(isnull(bar,'')))='';
    

提交回复
热议问题