-
Notifications
You must be signed in to change notification settings - Fork 32
/
imdb-load-data.sql
110 lines (87 loc) · 3.51 KB
/
imdb-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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
This script loads normalised IMDb data into IMDb database tables created by
using the script imdb-create-tables.sql.
To use the IMDb scripts:
1) Open MySQL in terminal:
$ mysql -u root -p --local-infile
2) Create IMDb data base in MySQL:
mysql> SOURCE /Users/lappy/Git_repos_mine/MySQL_IMDb_Project/imdb-create-tables.sql
3) Load data using this script in MySQL:
mysql> SOURCE /Users/lappy/Git_repos_mine/MySQL_IMDb_Project/imdb-load-data.sql
4) Add constraints to the IMDb database in MySQL
mysql> SOURCE /Users/lappy/Git_repos_mine/MySQL_IMDb_Project/imdb-add-constraints.sql
5) Add indexes to the IMDb database in MySQL
mysql> SOURCE /Users/lappy/Git_repos_mine/MySQL_IMDb_Project/imdb-index-tables.sql
*/
-- SHOW VARIABLES LIKE "local_infile";
SET GLOBAL local_infile = 1;
-- Load Aliases.tsv into Aliases table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Aliases.tsv'
INTO TABLE Aliases
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Alias_attributes.tsv into Alias_attributes table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Alias_attributes.tsv'
INTO TABLE Alias_attributes
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Alias_types.tsv into Alias_types table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Alias_types.tsv'
INTO TABLE Alias_types
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Directors.tsv into Directors table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Directors.tsv'
INTO TABLE Directors
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Writers.tsv into Writers table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Writers.tsv'
INTO TABLE Writers
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Episode_belongs_to.tsv into Episode_belongs_to table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Episode_belongs_to.tsv'
INTO TABLE Episode_belongs_to
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Names_.tsv into Names_ table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Names_.tsv'
INTO TABLE Names_
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Name_worked_as.tsv into Name_worked_as table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Name_worked_as.tsv'
INTO TABLE Name_worked_as
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Known_for.tsv into Known_for table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Known_for.tsv'
INTO TABLE Known_for
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Principals.tsv into Principals table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Principals.tsv'
INTO TABLE Principals
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Had_role.tsv into Had_role table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Had_role.tsv'
INTO TABLE Had_role
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Titles.tsv into Titles table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Titles.tsv'
INTO TABLE Titles
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Title_genres.tsv into Title_genres table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Title_genres.tsv'
INTO TABLE Title_genres
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;
-- Load Title_ratings.tsv into Title_ratings table
LOAD DATA LOCAL INFILE '/Users/lappy/Git_repos_mine/MySQL_IMDb_Project/Title_ratings.tsv'
INTO TABLE Title_ratings
COLUMNS TERMINATED BY '\t'
IGNORE 1 LINES;