This repository has been archived by the owner on Mar 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.txt
19 lines (16 loc) · 1.87 KB
/
create.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
create database users;
use users;
create table customers (id int auto_increment, global_id int, orders_created int, money_in_orders bigint, registered DATETIME, gain bigint, primary key (id), unique(global_id), index(registered));
create table executors (id int auto_increment, global_id int, orders_completed int, money_received bigint, registered DATETIME, gain bigint, primary key (id), unique(global_id), index(registered));
create database interactions;
use interactions;
create table orders (id int auto_increment, customer_id int, status varchar(20), description varchar(8000), money_cost bigint, original_currency char(3), created DATETIME, last_action DATETIME, primary key (id), index(customer_id), index(last_action));
create table contracts (id int auto_increment, customer_id int, executor_id int, status varchar(20), description varchar(8000), money_cost bigint, original_currency char(3), created DATETIME, last_action DATETIME, primary key (id), index(customer_id), index(executor_id), index(last_action));
insert into contracts values(1, 123, 666, "CREATED", "a test order #1", "1234000000", "RUR", curtime(), curtime());
insert into orders values(1, 123, "CREATED", "a test order #1", "777000000", "RUR", curtime(), curtime());
insert into orders values(2, 234, "CREATED", "a test order #2", "888000000", "RUR", curtime(), curtime());
CREATE USER 'vktech'@'localhost' IDENTIFIED BY 'vktech';
GRANT ALL PRIVILEGES ON interactions.* TO 'vktech'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON users.* TO 'vktech'@'localhost' WITH GRANT OPTION;
GRANT RELOAD,PROCESS ON *.* TO 'vktech'@'localhost';
INSERT INTO users.executors SELECT id, global_id, orders_completed, money_received, registered, gain FROM users.executors WHERE global_id=100 ON DUPLICATE KEY UPDATE orders_completed=values(orders_completed)+1, money_received = values(money_received)+76146000000, gain = values(gain)+1554000000;