forked from neilkod/oow-vote-hacking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_data.sql
42 lines (34 loc) · 1.11 KB
/
load_data.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
-- script for MySQL
drop table sessions;
drop table votes;
drop table users;
drop table final_vote_count;
drop table all_votes;
create table sessions (
session_id int primary key,
title varchar(100),
user_id int
);
create table votes (
id integer primary key auto_increment,
session_id int,
user_id int
);
create table users (
user_id int primary key,
name varchar(100)
);
create table final_vote_count (
session_id int,
total_votes int
);
create table all_votes (
id integer primary key auto_increment,
session_id int,
user_id int
);
LOAD DATA LOCAL INFILE 'sessions.dat' INTO TABLE sessions FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"';
LOAD DATA LOCAL INFILE 'votes.dat' INTO TABLE votes FIELDS TERMINATED BY '|' (session_id, user_id);
LOAD DATA LOCAL INFILE 'users.dat' INTO TABLE users FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"';
LOAD DATA LOCAL INFILE 'final_vote_count.dat' INTO TABLE final_vote_count FIELDS TERMINATED BY '|';
LOAD DATA LOCAL INFILE 'all_votes.dat' INTO TABLE all_votes FIELDS TERMINATED BY '|' (session_id, user_id);