Why can't I add a not null column when modifying a table

  • This is a logical problem, when you modify a table to add a new column, the SQL engine need to modify each row in the table. The first step of the row modification is to add an empty column, then it will try assign the data if you ask for it.
  • Not null is by definition a NOT empty column.

To add a not null column when modifying a table:

  1. Add the column as: allow nulls.
  2. Add the data.
  3. Modify the table and change that column to: do not allow nulls.