Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
最初,表“MyTable”已按以下方式定义:
CREATE TABLE IF NOT EXISTS `MyTable` ( `Col1` smallint(6) NOT NULL AUTO_INCREMENT, `Col2` smallint(6) DEFAULT NULL, `Col3` varchar(20) NOT NULL, );
如何以允许“Col 3”列为 NULL 的方式更新它?
ALTER TABLE MyTable MODIFY Col3 varchar(20) NULL;
以下 MySQL 语句应修改您的列以接受 NULL。
ALTER TABLE `MyTable` ALTER COLUMN `Col3` varchar(20) DEFAULT NULL