One way to solve it is by using the command alter table ... modify ...
. For more information see manual 5.7
, manual 8.0
.
To execute the command below I used the definition of create table
that is in your question.
Follow the DDL:
ALTER TABLE usuarios MODIFY COLUMN nome VARCHAR(64) NULL;
-- Query OK, 0 rows affected (0.01 sec)
-- Records: 0 Duplicates: 0 Warnings: 0
A second way:
ALTER TABLE usuarios MODIFY COLUMN nome VARCHAR(64);
Notice that we have omitted the word NULL
in relation to the first.
Now the DML:
INSERT INTO usuarios (nome, email) VALUES(null, '[email protected]');
-- Query OK, 1 row affected (0.01 sec)
INSERT INTO usuarios (nome, email) VALUES('eu', '[email protected]');
-- Query OK, 1 row affected (0.01 sec)
I used mysql 5.6 (via sqlfiddle), 5.7 and 8.0.22 ( @Augusto Vasques partnership)
alter table TABELA alter column COLUNA null
? https://dev.mysql.com/doc/refman/8.0/en/alter-table.html– Ricardo Pontual