forked from pamelaborges/dio-bd-relacional
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aula5-3.sql
48 lines (39 loc) · 2.44 KB
/
aula5-3.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
-- Inserindo massa de dados --
INSERT INTO usuarios (nome, email, data_nascimento, rua) VALUES
('João Silva', '[email protected]', '1990-01-01', 'Rua A'),
('Maria Santos', '[email protected]', '1992-03-15', 'Rua B'),
('Pedro Almeida', '[email protected]', '1985-07-10', 'Rua C'),
('Ana Oliveira', '[email protected]', '1998-12-25', 'Rua D'),
('Carlos Pereira', '[email protected]', '1991-06-05', 'Rua E'),
('Laura Mendes', '[email protected]', '1994-09-12', 'Rua F'),
('Fernando Santos', '[email protected]', '1988-02-20', 'Rua G'),
('Mariana Costa', '[email protected]', '1997-11-30', 'Rua H'),
('Ricardo Rodrigues', '[email protected]', '1993-04-18', 'Rua I'),
('Camila Alves', '[email protected]', '1989-08-08', 'Rua J'),
('Bruno Carvalho', '[email protected]', '1995-03-25', 'Rua K'),
('Amanda Silva', '[email protected]', '1996-12-02', 'Rua L'),
('Paulo Mendonça', '[email protected]', '1999-07-20', 'Rua M'),
('Larissa Oliveira', '[email protected]', '1987-10-15', 'Rua N'),
('Fernanda Sousa', '[email protected]', '1992-05-08', 'Rua O'),
('Gustavo Santos', '[email protected]', '1993-09-18', 'Rua P'),
('Helena Costa', '[email protected]', '1998-02-22', 'Rua Q'),
('Diego Almeida', '[email protected]', '1991-11-27', 'Rua R'),
('Juliana Lima', '[email protected]', '1997-04-05', 'Rua S'),
('Rafaela Silva', '[email protected]', '1996-01-10', 'Rua T'),
('Lucas Pereira', '[email protected]', '1986-08-30', 'Rua U'),
('Fábio Rodrigues', '[email protected]', '1989-03-12', 'Rua V'),
('Isabela Santos', '[email protected]', '1994-12-07', 'Rua W'),
('André Alves', '[email protected]', '1995-09-28', 'Rua X'),
('Clara Carvalho', '[email protected]', '1990-02-15', 'Rua Y'),
('Roberto Mendes', '[email protected]', '1992-07-21', 'Rua Z'),
('Mariana Oliveira', '[email protected]', '1997-05-03', 'Av. A'),
('Gustavo Costa', '[email protected]', '1998-11-16', 'Av. B'),
('Lara Sousa', '[email protected]', '1993-06-09', 'Av. C'),
('Pedro Lima', '[email protected]', '1996-09-27', 'Av. D');
EXPLAIN SELECT * FROM usuarios WHERE nome = "Maria";
EXPLAIN SELECT * FROM usuarios us
INNER JOIN reservas rs
ON us.id = rs.id_usuario
WHERE nome = "Maria";
CREATE INDEX idx_nome ON usuarios (nome);
EXPLAIN SELECT * FROM usuarios WHERE nome = "Maria";