Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
The UPDATE statement is a Structured Query Language (SQL) statement used to change or update values in a table. It is usually suffixed with a WHERE clause to restrict the change to a set of values that meet a specific set of criteria.
The general syntax of an UPDATE statement is:
UPDATE table_name SET column1=value1, column2=value2 WHERE column=condition
For example, in the Customer_master table, if a change needs to be made to both Andrew Smith’s email address (to firstname.lastname@example.org) and his date of birth (to February 17, 1985), the syntax would be:
UPDATE customer_master SET email_addr="email@example.com", date_of_birth="02.17.1985" WHERE customer_name="Andrew Smith"
Note the importance of the WHERE clause in acting as a restriction on which rows of data are to be changed. Without the WHERE clause, the statement will update the entire table, setting all customers’ email addresses to firstname.lastname@example.org and all customers’ dates of birth to February 17, 1985.
To update a table, a username must be granted the privilege to do so by the database administrator. Even while using an application, when data is changed (like Andrew Smith’s email address above), the application is really sending the equivalent UPDATE statement like the one above to execute on the database.