0

I am using mySQL and am trying to get my head around the difference between NULL and empty. If I add a column to my table using...

alter table data add result VARCHAR(4);

Then every field in the column is automatically populated with NULL.

Does this take up any more space than an empty field? How could I add that column with blank values instead?

fightstarr20
  • 11,682
  • 40
  • 154
  • 278

1 Answers1

0

You can use default, if you don;t like nulls, but Null is more descriptive:

alter table data add result VARCHAR(4) DEFAULT ''

Generally you should be using null, as it means -none has set a value to this column.

As for the space I am not aware is MySQL is treating empty values, but I assume that NULL takes less space, because NULL is generally a singleton in most languages.

Beri
  • 11,470
  • 4
  • 35
  • 57