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?

5
  • Tag your question with the database you are using. Commented Apr 24, 2018 at 17:38
  • Possible duplicate of Altering a column: null to not null Commented Apr 24, 2018 at 17:42
  • Which 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, ... Commented Apr 24, 2018 at 17:46
  • mysql workbench Commented Apr 24, 2018 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. Commented Apr 24, 2018 at 20:06

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.