This post was originally published on Pure Storage
In any application, you need to add records to database tables and change information they store. The UPDATE SQL statement changes data already stored in the database, and the INSERT statement adds a new record to a table. The UPSERT statement is a combination of INSERT and UPDATE and performs an update or adds a record if it doesn’t already exist.
How to Use UPDATE in SQL: Examples
The UPDATE statement updates a current record with new information that you specify. For example, a customer might move and change their contact information in an e-commerce table, and an UPDATE statement will perform the change. Any changes you make in a database will use the UPDATE statement.
UPDATE in SQL: Examples
For most SQL UPDATE statements, you use the WHERE clause. The WHERE clause determines which records will be updated and leaves the others untouched. If you don’t use a WHERE clause when executing an UPDATE statement, the database will make changes to all records in the database, which is likely an error. Make sure you have a WHERE clause in your SQL statement to avoid this mistake.
The UPDATE statement syntax depends on the database engine that you use. The
— Read the rest of this post, which was originally published on Pure Storage.