I am busy studying MySQL and I understand that update is used to update a record or row in a table. So what does alter do that is so different? Seems like they are the same.
Thanks, any help will be appreciated.
Summary. The alter command is used when we want to modify a database or any object contained in the database. The drop command is used to delete databases from MySQL server or objects within a database. The rename command is used to change the name of a table to a new table name.
Update is used to modify/update already existing data. If the data is not found it will give an error. Alter is used to add, delete, or modify columns in existing table it is also used to add or drop constrains.
ALTER
is a DDL (Data Definition Language) statement. Whereas UPDATE
is a DML (Data Manipulation Language) statement. ALTER
is used to update the structure of the table (add/remove field/index etc). Whereas UPDATE
is used to update data.
The ALTER
changes the table in the database, you can add or remove columns, etc. But it does not change data (except in the dropped or added columns of course).
While the UPDATE
changes the rows in the table, and leaves the table unchanged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With