How to detect and remove a column that contains only null values?

后端 未结 6 2418
说谎
说谎 2020-12-30 14:50

In my table table1 there are 6 columns Locations,a,b,c,d,e.

Locations [a]   [b]   [c]  [d]   [e]

[1]       10.00 Null  Null 20.00 Null

[2]         


        
6条回答
  •  情话喂你
    2020-12-30 15:09

    SELECT * FROM table1 WHERE c IS NOT NULL  -- or also SELECT COUNT(*)
    

    To detect if indeed this column has no values at all.

    ALTER TABLE table1 DROP COLUMN c
    

    is the query to remove the column if it is deemed desirable.

提交回复
热议问题