---
title: "What is the purpose of the UPDATE statement in SQL, explain with an example."  
description: "What is the purpose of the UPDATE statement in SQL, explain with an example."  
author: "Steilla Mitchel"  
published: 2023-08-30  
updated: 2023-08-31  
canonical: https://www.mindstick.com/forum/159773/what-is-the-purpose-of-the-update-statement-in-sql-explain-with-an-example  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 2 minutes  

---

# What is the purpose of the UPDATE statement in SQL, explain with an example.

What is the [purpose](https://yourviews.mindstick.com/view/247/no-fail-policy-failing-its-purpose) of the [UPDATE](https://www.mindstick.com/forum/156353/what-is-hummingbird-update) [statement in SQL](https://www.mindstick.com/forum/33706/what-is-the-difference-between-having-clause-and-group-by-statement-in-sql-server), [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) with an example.

## Replies

### Reply by Aryan Kumar

The UPDATE statement in [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) is used to modify the existing records in a table. The basic syntax of the UPDATE statement is:

SQL

```plaintext
UPDATE table_name SET column1 = value1, column2 = value2, ... [WHERE condition];
```

The `table_name` is the name of the table that you want to update. The `column1`, `column2`, etc. are the columns that you want to update. The `value1`, `value2`, etc. are the new values for the columns. The `WHERE condition` is an optional clause that specifies the rows that you want to update. If you omit the `WHERE condition`, all rows in the table will be updated.

For example, the following statement will update the `name` column of all rows in the `customers` table to "John Doe":

SQL

```plaintext
UPDATE customers SET name = 'John Doe';
```

The following statement will update the `name` column of the row where the `id` is 1 to "Jane Doe":

SQL

```plaintext
UPDATE customers SET name = 'Jane Doe' WHERE id = 1;
```

The UPDATE statement is a powerful tool that can be used to modify data in a table. It is important to use it carefully, as it can be irreversible.

Here are some additional things to keep in mind when using the UPDATE statement:

- The UPDATE statement is a DML (Data Manipulation Language) statement. DML statements are not reversible, so it is important to make sure that you are updating the correct data.
- You can use the `WHERE` clause to specify the rows that you want to update. If you omit the `WHERE` clause, all rows in the table will be updated.
- You can update multiple columns in a single UPDATE statement.
- You can use the `SET` clause to specify the new values for the columns.


---

Original Source: https://www.mindstick.com/forum/159773/what-is-the-purpose-of-the-update-statement-in-sql-explain-with-an-example

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
