-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
32 lines (27 loc) · 902 Bytes
/
init.sql
File metadata and controls
32 lines (27 loc) · 902 Bytes
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
CREATE DATABASE IF NOT EXISTS my_database;
USE my_database;
CREATE TABLE IF NOT EXISTS my_table (
id INT,
Entity VARCHAR(255),
Code VARCHAR(10),
Year INT,
Cellular_Subscription INT,
Internet_Users_Percent DECIMAL(5, 2),
No_of_Internet_Users INT,
Broadband_Subscription INT,
PRIMARY KEY (Entity, Year)
);
LOAD DATA LOCAL INFILE '/docker-entrypoint-initdb.d/dataset.csv'
INTO TABLE my_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 ROWS
(@id, Entity, Code, Year, Cellular_Subscription, Internet_Users_Percent, No_of_Internet_Users, Broadband_Subscription);
-- Eliminar todos los registros donde Code sea 'Region'
DELETE FROM my_table WHERE Code = 'Region';
CREATE TABLE IF NOT EXISTS high_score (
id INT AUTO_INCREMENT PRIMARY KEY,
score INT NOT NULL
);
-- Inicializar con una puntuación de 0
INSERT INTO high_score (score) VALUES (0);