Search code examples
mysqlsqlnulldefaultalter-table

How to Change Default Null to NOT NULL in MySQL


I have the following column in table room Now I want to change the definition of column property_id from NULL to NOT NULL How can I do this following Query is not working

ALTER TABLE `room` CHANGE `property_id` `property_id` bigint(20)  NOT NULL;

Actual definition of Column is :

 `property_id` bigint(20) DEFAULT NULL,

Solution

  • My Query was perfectly fine , The only mistake is that there are some rows that contains null record so that why it is creating an issue