Transactions
Redpanda SQL accepts transaction syntax for compatibility with tools that require it. However, queries execute immediately, and Redpanda SQL provides no transactional guarantees.
Commands
Use the following commands to manage transactions:
BEGIN
Initiates a new transaction by calling one of the following.
BEGIN;
BEGIN TRANSACTION;
Examples
-
Define a table named
productswith columns:product_name,price, andstock_quantity.CREATE TABLE productsnew( product_name TEXT, price INT, stock_quantity INT );Upon successful creation, you get the following output.
CREATE -
Next, insert product data into the
productstable.
|
BEGIN;
INSERT INTO productsnew(product_name, price, stock_quantity) VALUES ('Tab', 8000, 20);
This returns the following output:
BEGIN
INSERT 0 1
-
View the changes by displaying the products table:
SELECT * FROM productsnew; COMMIT;The product data is now added to the table.
product_name | price | stock_quantity --------------+-------+---------------- Tab | 8000 | 20 (1 row) COMMIT