Skip to main content
Post Undeleted by D-Shih
added 128 characters in body
Source Link
D-Shih
  • 46.5k
  • 6
  • 37
  • 56

You can try to use UPDATE let typeALTER column set thea default value.

then ALTER column be not null.

UPDATE T SET type = '' WHERE type IS NULL; ALTER TABLE `T` MODIFY `type` varchar(50) NOTDEFAULT NULL;'default'; 

then insert by DEFAULT keyword:

INSERT INTO T (type) VALUES (DEFAULT); 

Results:

You can try to use UPDATE let type column set the default value.

then ALTER column be not null.

UPDATE T SET type = '' WHERE type IS NULL; ALTER TABLE `T` MODIFY `type` varchar(50) NOT NULL; 

You can try to ALTER column set a default value.

ALTER TABLE `T` MODIFY `type` varchar(50) DEFAULT 'default'; 

then insert by DEFAULT keyword:

INSERT INTO T (type) VALUES (DEFAULT); 

Results:

Post Deleted by D-Shih
Source Link
D-Shih
  • 46.5k
  • 6
  • 37
  • 56

You can try to use UPDATE let type column set the default value.

then ALTER column be not null.

UPDATE T SET type = '' WHERE type IS NULL; ALTER TABLE `T` MODIFY `type` varchar(50) NOT NULL;