-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaction.sql
46 lines (31 loc) · 1.26 KB
/
transaction.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
truncate order_history;
truncate trial_history;
START TRANSACTION;
INSERT INTO trial_history(PHONE_NUMBER, Product_id) VALUES ('1234567890', 1);
SAVEPOINT before_conflict;
INSERT INTO trial_history(PHONE_NUMBER, Product_id) VALUES ('1234567890', 1);
ROLLBACK TO SAVEPOINT before_conflict;
INSERT INTO trial_history(PHONE_NUMBER, Product_id) VALUES ('4567890123', 2);
COMMIT;
START TRANSACTION;
INSERT INTO order_history(PHONE_NUMBER, Product_id,Quantity) VALUES ('1234567890', 1,2);
SAVEPOINT before_conflict;
INSERT INTO order_history(PHONE_NUMBER, Product_id,Quantity) VALUES ('1234567890', 1,2);
ROLLBACK TO SAVEPOINT before_conflict;
INSERT INTO order_history(PHONE_NUMBER, Product_id,Quantity) VALUES ('4567890123', 2,5);
COMMIT;
START TRANSACTION;
INSERT INTO trial_history (PHONE_NUMBER, Product_id) VALUES ('1112223334', 4);
COMMIT;
SELECT * from trial_history;
START TRANSACTION;
UPDATE trial_history SET Product_id = 3 WHERE PHONE_NUMBER = '1112223334';
COMMIT;
SELECT * from trial_history;
START TRANSACTION;
SELECT * FROM trial_history WHERE PHONE_NUMBER = '1112223334';
COMMIT;
START TRANSACTION;
DELETE FROM trial_history WHERE PHONE_NUMBER = '1112223334';
COMMIT;
SELECT * from trial_history;