1

I have the following column

 `Equipamento_Solucao_id` VARCHAR(32) NOT NULL,

I would like it to be

`Equipamento_Solucao_id` VARCHAR(32) DEFAULT NULL,

How can I do this without changing my database model, that is, with a sql query?

duplode
  • 33,731
  • 7
  • 79
  • 150
Pedro Martins
  • 158
  • 2
  • 9
  • Tag your question with the database you are using. – Gordon Linoff Apr 24 '18 at 17:38
  • Possible duplicate of [Altering a column: null to not null](https://stackoverflow.com/questions/689746/altering-a-column-null-to-not-null) – Dorado Apr 24 '18 at 17:42
  • Which [DBMS](https://en.wikipedia.org/wiki/DBMS) are you using? "SQL" is just a query language, not the name of a specific database product. Please add the tag for the database product you are using `postgresql`, `oracle`, `db2`, `sql-server`, ... –  Apr 24 '18 at 17:46
  • mysql workbench – Pedro Martins Apr 24 '18 at 18:05
  • Not to be too pedantic, but the DBMS you are using is mysql. MySQL Workbench is the development environment you are using to interact with the DBMS. – Honeyboy Wilson Apr 24 '18 at 20:06

1 Answers1

1

You would use an alter table statement. A typical method would be:

alter table t alter column Equipamento_Solucao_id VARCHAR(32) DEFAULT NULL;

You could also look through the system tables on your database, find the not-null constraint, and then drop it specifically.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786