mysql數據的transaction語句使用示例
时间: 2024-06-01 07:11:13 浏览: 76
mysql sql语句示例
1. 示例1-基本的transaction语句
BEGIN;
UPDATE table_name SET column_1=value_1 WHERE condition;
COMMIT;
2. 示例2-使用ROLLBACK回滚语句
BEGIN;
UPDATE table_name SET column_1=value_1 WHERE condition;
UPDATE table_name SET column_2=value_2 WHERE condition;
ROLLBACK;
3. 示例3-使用SAVEPOINT和ROLLBACK TO回滚到保存点
BEGIN;
UPDATE table_name SET column_1=value_1 WHERE condition;
SAVEPOINT savepoint_name;
UPDATE table_name SET column_2=value_2 WHERE condition;
ROLLBACK TO savepoint_name;
COMMIT;
4. 示例4-使用SET TRANSACTION语句设置隔离级别
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN;
UPDATE table_name SET column_1=value_1 WHERE condition;
COMMIT;
阅读全文