SQL 语法

 

Transactional and Locking

更新时间 2023-09-06

在 Transactional and Locking 语法上, RadonDB 与 MySQL 兼容。

Transaction

  • 支持多语句事务。

  • 必须开启 RadonDB 参数 twopc-enable

  • 支持单条事务 autocommittwopc-enable 值为 ON

语法

BEGIN
COMMIT
ROLLBACK

示例

mysql> create table txntbl(a int);
Query OK, 0 rows affected (0.01 sec)

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into txntbl(a) values(1),(2);
Query OK, 4 rows affected (0.00 sec)

mysql> select * from txntbl;
+------+
| a    |
+------+
|    1 |
|    2 |
+------+
2 rows in set (0.01 sec)

mysql> rollback;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from txntbl;
Empty set (0.00 sec)

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into txntbl(a) values(1),(2);
Query OK, 4 rows affected (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from txntbl;
+------+
| a    |
+------+
|    1 |
|    2 |
+------+
2 rows in set (0.00 sec)
这篇文档解决了您的问题吗?
0
0