A manager at a retail company needs to adjust the price of an item in their inventory database due to a recent change in supplier costs. Using appropriate commands, how would they modify the existing price for this item without affecting any other records in the database?
By using an INSERT statement with the new price for the item ID.
By deleting the item and adding it again with the new price.
By using an UPDATE statement to change the item's price where the item ID matches the specific product.
By using a SELECT statement with the new price where the item ID matches the specific product.
The correct approach is to use an UPDATE statement that changes the price only for the row whose item ID matches the product in question (for example: UPDATE inventory SET price = new_price WHERE item_id = 123;). The UPDATE statement is designed to modify existing data, and the WHERE clause ensures that only the intended record is changed. An INSERT statement would add a new record instead of changing the existing one, a SELECT statement merely retrieves data, and deleting and re-adding the row introduces unnecessary risk to referential integrity and audit trails.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is an UPDATE statement in SQL?
Open an interactive chat with Bash
What is the purpose of the WHERE clause in an UPDATE statement?
Open an interactive chat with Bash
Why shouldn't you use an INSERT statement to update existing records?