What is the difference between CHANGE and MODIFY in SQL?
In specific I am talking about the lecture on NOT NULL Constraint.
Where to set a field to null we used MODIFY COLUMN but when dropping this constraint we used CHANGE COLUMN.
I tried using MODIFY COLUMN for both tasks and the results are the same, so does that mean that they are interchangeable (apart from the fact that with CHANGE COLUMN you have to repeat the name of the column).
Thanks for reaching out.
Sometimes the two options can be used as alternatives. In other situations, you can use only one or the other. For instance, as Vladimir suggested – With CHANGE you are able to change the name of a column while using MODIFY disallows that.
Throughout the course, we’ve used both to show that both can be used and because we did not want to deprive the course code from any of the two options.
That said, both are good to go in the NOT NULL Constraint lecture, as they can be interchangeable. Basically, the only difference is that you can alter a columns’ name when using CHANGE.
Hope this helps.