SQL multivolume atomatics question

I am trying to create a program that updates two different tables using sql commands. The only thing that bothers me is that if the program updates one of the tables and then loses the connection or something else and does NOT update the other table, a problem may occur. Is there a way I could

and. Update them at the same time.

or

C. Return the first update if the second fails.

+3
source share
3 answers

Yes uses transaction SQL. Here is a tutorial: JDBC transactions

+8
source

. :

  • MySQL
  • Oracle
  • SQL Server
  • PostgreSQL

( - ​​ , ), ... , ( SQL-), , - .

+2

SQL- , .. , . :

START TRANSACTION;
 *do stuff*
COMMIT;

, , . , MySQL.

+1
source

Source: https://habr.com/ru/post/1776499/


All Articles