0

Updating Data - SQL

Hi everybody! I've got a question here in this lesson. To update John's salary, we can use the following query: UPDATE Employees SET Salary=5000 WHERE ID=1; We learned that we should NOT forget the WHERE statement, because "If you omit the WHERE clause, all records in the table will be updated!" What if I forgot the WHERE part? Does that mean I have to type all the salaries all over again or is there any way to undo this? Thanks in advance!

4th Sep 2019, 3:01 PM
Samar Ibrahim
3 Antworten
+ 2
Backup is good solotion
4th Sep 2019, 4:51 PM
Moh Waleed Sharifi
+ 1
Yes, salary in all rows will be updated. No, you can't undo this, only write data again. But if you will have a backup of database - it's will be very nice!
4th Sep 2019, 3:27 PM
id001x
id001x - avatar
0
In some database engines you can undo your last 'transaction' with the ROLLBACK command. (Unless autocommit is enabled.)
4th Sep 2019, 6:15 PM
Tibor Santa
Tibor Santa - avatar