SQL Transaction Control (TC), COMMIT ROLLBACK, SAVEPOINT statements

The language SQL (Structured Query Language) is a database language that allows you to access databases.

This language is used to access the main databases existing today such as SQL Server Microsoft or Oracle database, of course the syntax between these two databases may have some differences, but the basic commands are practically the same.

 

SQL Instruções TC (Transaction Control), COMMIT ROLLBACK, SAVEPOINT
SQL Transaction Control (TC), COMMIT ROLLBACK, SAVEPOINT statements

TC (Transaction Control) Instructions

In Transaction Control we have three commands: COMMIT ROLLBACK, SAVEPOINT. Below we will see what these commands do.

COMMIT – This command serves to confirm an action within a database, for example:

Let's say you asked to delete data within the database

  • DELETE FROM patient ONDE name='John'

Once the deletion is confirmed, we can use the command COMMIT which confirms this deletion. But be careful, using the COMMIT it is irreversible. This command is useful when we work with multiple users and have a section control, using COMMIT it's like you're forcing your action to be visible to everyone in the bank.

 

SAVEPOINT – This command has a function similar to the Windows “Restore Point” function. With it you can create a reference point and if you want to undo an action with ROLLBACK, the action returns to the SAVEPOINT created.

 

ROLLBACK - This command is used to undo changes to a restore point defined by SAVEPOINT.

 881 Total Visualizações,  1 Visualizações Hoje

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.