Modifying Data
Explore how to modify and manage data within SQL databases by learning to use the UPDATE and DELETE FROM statements. This lesson helps you understand how to correct erroneous entries and remove unwanted records while maintaining data accuracy and integrity.
We'll cover the following...
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 ...