BEGIN

Commits any existing open transaction on the current connection and starts a new transaction.

Syntax

START TRANSACTION | BEGIN [WORK]

Remarks

  • This command must be run on the master aggregator or a child aggregator node (see Node Requirements for SingleStore Commands. Note that you must connect to the master aggregator when running this command on reference tables.

  • When BEGIN is used to start a transaction, it overrides the behavior of autocommit engine variable for this transaction, and the transaction must be ended explicitly with COMMIT or ROLLBACK.

  • If the transaction is successful, execute the COMMIT command to commit the changes; if the transaction is unsuccessful or needs to be reverted, then execute the ROLLBACK command to revert the changes.

  • The maximum number of tables that can be written into a single transaction is 1024. If the transaction table writes exceed the maximum amount, an error will be generated. Execute the ROLLBACK command to revert any changes. Then split the transaction into smaller sections and execute again.

Example

For this example, consider the following Employee table:

ID

Name

30

Jim

20

Rob

40

Rick

BEGIN;
UPDATE Employee SET Name = "John" WHERE ID = 300;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

Run the SELECT query to verify if the UPDATE is correct:

SELECT * FROM Employee;
+------+-------+
| ID   | Name  |
+------+-------+
|   30 | Jim   |
|   20 | Rob   |
|   40 | Rick  |
+------+-------+

Run ROLLBACK since there were no matching results for the ID and the UPDATE was not successful.

ROLLBACK;

Note: Before the user runs COMMIT or ROLLBACK, only that user can see the updates made after BEGIN was run.

Last modified: October 1, 2024

Was this article helpful?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK