BEGIN;DELETE FROM customers WHERE id = 1;DELETE orders WHERE customer = 1;COMMIT;
For more information about how to use the built-in SQL client, see the reference docs.
The best way to run a multi-statement transaction from Go code is to use one of the following approaches:
Use the crdb transaction wrapper which automatically handles transaction retry errors if they occur, as shown in .
Write your own retry loop wrapper, as shown in
The best way to run a multi-statement transaction from Java is to write a wrapper method that automatically handles transaction retry errors.For complete examples showing how to write and use such wrapper methods, see .
The best way to run a multi-statement transaction from Python code is to use one of the following approaches:
Use the sqlalchemy-cockroachdb SQLAlchemy dialect, which automatically handles transaction retry errors if they occur, as shown in .