Modifying Data

Learn how to use the UPDATE statement to modify the data in the database.

Sometimes, data is inserted erroneously in the database. This can involve two types of mistakes: inserting a wrong value against a certain field or mistakenly inserting an entire record. Alongside rectifying such inconsistencies, we also need ongoing management and synchronization of data, such as ensuring that a person’s address remains current and accurate. Situations like these require making alterations to the data. For this purpose, we employ the UPDATE and DELETE FROM statements in SQL as and when needed. These are explained below:

The UPDATE statement

Consider a scenario where an error exists in one of the records, necessitating correction. For example, let’s consider a sale with SaleID 3, where the current sales amount is inaccurately recorded as 50, while the correct amount should be 35. To rectify this discrepancy, we need to update the record. In SQL, we have the UPDATE statement that is utilized for this purpose. The typical format of this statement is outlined as follows:

Get hands-on with 1400+ tech skills courses.