Reputation: 644
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,
Upvotes: 1
Views: 9607
Reputation: 644
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
Upvotes: 1
Reputation: 309
In mysql you can achieve this as,
ALTER TABLE room MODIFY property_id bigint(20) not null;
Upvotes: 3