我试图在不丢失数据的情况下删除 sqlserver2008中的非空约束。
ALTER TABLE YourTable ALTER COLUMN YourColumn columnType NULL
将约束 not null移除到 null
not null
null
ALTER TABLE 'test' CHANGE COLUMN 'testColumn' 'testColumn' datatype NULL;
删除列约束: 从 not null到 null
ALTER TABLE test ALTER COLUMN column_01 DROP NOT NULL;
参考资料: https://www.tutorialspoint.com/How-can-we-remove-NOT-NULL-constraint-from-a-column-of-an-existing-MySQL-table
ALTER TABLE tableName MODIFY columnName columnType NULL;