· 5 years ago · Jun 19, 2020, 08:08 AM
1create database if not exists STT;
2
3create user 'STT'@'%' identified by 'STT';
4
5grant all privileges on *.* to 'STT'@'%';
6flush privileges;
7
8set global sql_mode = '';
9
10CREATE TABLE users(
11 id INT(16) NOT NULL,
12 wallet DECIMAL(13, 2) NOT null,
13 address VARCHAR(20) NOT NULL
14);
15
16CREATE TABLE transaction_log(
17 userId INT(16) NOT NULL,
18 amount DECIMAL(13, 2) NOT NULL,
19 addressTo VARCHAR(20) NOT NULL,
20 processed_at TIMESTAMP NOT NULL
21);
22
23insert into transaction_log (userId, amount, addressTo) values (101, 0.2, "22222")
24
25select * from transaction_log;
26
27drop table transaction_log;
28
29insert into users (id, wallet, address) values (101, 500.5, "11111")
30insert into users (id, wallet, address) values (202, 50.10, "22222")
31
32select max(processed_at) from transaction_log
33
34
35
36
37set autocommit=0
38commit
39
40SET GLOBAL general_log = 'ON';
41SET global general_log = 1;
42SET autocommit=0;
43
44SELECT * FROM users
45SET SESSION TRANSACTION ISOLATION LEVEL READ committed ;
46begin;
47SELECT * FROM users WHERE id = 101 for update
48
49SHOW CREATE TABLE mysql.general_log;
50
51SET global general_log = 1;
52SET global log_output = 'table';
53
54
55select * from mysql.general_log;
56
57SELECT * FROM users WHERE id = 101
58commit;
59UPDATE users SET wallet = 20 WHERE id = 202