MySQL Alter table causes Error: Invalid use of NULL value

前端 未结 3 1687
甜味超标
甜味超标 2020-12-23 16:07

My existing table:

+-----------------+---------------+------+-----+---------+-------------------+
| Field           | Type          | Null | Key | Default |          


        
3条回答
  •  感情败类
    2020-12-23 16:40

    You can't use this query until you have NO NULL values in the creation_date column.

    Update your creation_date column with some default date and then alter the table.

    Like this

    UPDATE enterprise SET creation_date = CURRENT_TIMESTAMP WHERE creation_date IS NULL;
    
    ALTER TABLE enterprise MODIFY creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
    

提交回复
热议问题