Difference between Alter and Update SQL [closed]

安稳与你 提交于 2019-12-09 05:01:07

问题


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.


回答1:


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.




回答2:


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.




回答3:


ALTER is used to change things like table structures or stored procs, otherwise known as DDL statements.

ALTER table MyTable 
ADD MyNewColumn VARCHAR(100)

OR

ALTER PROC dbo.MyStoredProc


来源:https://stackoverflow.com/questions/11293042/difference-between-alter-and-update-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!