Updating a specific row in sql

Remember, you should be careful when using this command because once you execute COMMIT, you cannot reverse any change!So, after running ROLLBACK, where will we go back to? We see the information we had in the “Departments Duplicate” table at the beginning of this post.

updating a specific row in sql-14updating a specific row in sql-59updating a specific row in sql-57

One can always make a simple mistake that could result in the loss of a large amount of data. One last thing – to properly switch off the safe updates, reconnection to the database is required. It is used to update the values of existing records in a table.

So, let’s exit this connection and then reconnect, typing the password once again! In the previous post about SQL INSERT Statement, we inserted an employee under the number of 9-9-9-9-0-1, remember? The syntax to adhere to is UPDATE table name, the keyword SET, column names and the respective values assigned to them, and finally – WHERE, and a certain condition, or set of conditions, that must be satisfied.

After that moment, even if you run the ROLLBACK clause 20 times, you can get to the state of only the last COMMIT.

You cannot restore data to a state corresponding to an earlier COMMIT.

None of these two features will help us here, though.

That’s why we will continue without enabling this option. And please remember that after turning off the “Safe Updates” option, you must be very careful when updating and deleting data in My SQL.

In a nutshell, these are the SQL rules regarding transaction control.

We must be very careful when using COMMIT and ROLLBACK – in other words, when we are changing the state of our data set.

Please note that it will be very hard to practice these statements unless we switch off the following feature of Workbench.

We can expand the Edit tab from the Main Menu and opt for “Preferences”.

Check what we have in the “Departments duplicate” table – nine rows and two columns with information. For the sake of this exercise, we will change all the department numbers and names in this table. “Departments Duplicate” is a table now comprising identical rows!

Tags: , ,