DEV Community

Mohammed Samgan Khan
Mohammed Samgan Khan

Posted on • Updated on • Originally published at dev.to

what is better to remove a column or make it null in MySQL.

hi,

I am a bit confused, should I delete a column as the data in that col is not in use in the system or make it null so that the old data remains.

what's the better approach?

Top comments (4)

Collapse
 
rhymes profile image
rhymes

If you are sure you don't need the data, do a backup and then drop the column

Collapse
 
msamgan profile image
Mohammed Samgan Khan

drop - 1
null - 0

Collapse
 
rhymes profile image
rhymes

You'll also avoid selecting the data in case of SELECT *

Collapse
 
pankajsanam profile image
Pankaj

Agreed with rhymes. If you think you might need the data then keep/backup it otherwise remove the column. There is no point in keeping something that you won't use ever.