Bladeren bron

{pushing through}

Jacqueline Joson 5 jaren geleden
bovenliggende
commit
410dac8acb

+ 2
- 0
src/main/java/io/zipcoder/persistenceapp/PersistenceStarterApplication.java Bestand weergeven

@@ -20,3 +20,5 @@ public class PersistenceStarterApplication {
20 20
 		return registrationBean;
21 21
 	}
22 22
 }
23
+    //go to http://localhost:8080/console to see h2
24
+    //make sure h2url is this ---> jdbc:h2:mem:test

+ 1
- 1
src/main/resources/application-h2.properties Bestand weergeven

@@ -1,4 +1,4 @@
1 1
 spring.datasource.url=jdbc:h2:mem:test;Mode=Oracle
2 2
 spring.datasource.platform=h2
3 3
 spring.jpa.hibernate.ddl-auto=none
4
-spring.datasource.continue-on-error=true
4
+spring.datasource.continue-on-error=true

+ 45
- 0
src/main/resources/script.sql Bestand weergeven

@@ -0,0 +1,45 @@
1
+SELECT * FROM MOVIES
2
+
3
+INSERT INTO MOVIES(TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
4
+VALUES('Howard the Duck	', '110', 'Sci-Fi', '4.6', 'PG')
5
+VALUES('Lavalantula', '83', 'Horror', '4.7', 'TV-14')
6
+VALUES ('Starship Troopers', '129', 'Sci-Fi',	'7.2', 'PG-13')
7
+VALUES ('Waltz With Bashir', '90', 'Documentary', '8.0', 'R')
8
+VALUES ('Spaceballs', '96', 'Comedy', '7.1', 'PG')
9
+VALUES ('Monsters Inc.', '92', 'Animation', '8.1', 'G')
10
+VALUES('The Fellowship of the Ring', '228', 'Fantasy', '8.8', 'PG-13')
11
+VALUES('Logan', '141', 'Sci-Fi', '8.1', 'R')
12
+
13
+
14
+SELECT TITLE FROM MOVIES
15
+WHERE GENRE = 'Sci-Fi'
16
+
17
+SELECT TITLE FROM MOVIES
18
+WHERE IMDB_SCORE >= 6.5;
19
+
20
+SELECT TITLE FROM MOVIES
21
+WHERE RUNTIME < 100 AND (RATING = 'G' OR RATING = 'PG')
22
+
23
+SELECT AVG (RUNTIME)
24
+FROM MOVIES
25
+WHERE IMDB_SCORE < 7.5
26
+GROUP BY genre;
27
+
28
+UPDATE MOVIES
29
+SET RATING = 'R'
30
+WHERE TITLE = 'Starship Troopers'
31
+
32
+SELECT ID, TITLE, RATING FROM MOVIES
33
+WHERE GENRE = 'Horror' OR GENRE = 'Documentary'
34
+
35
+SELECT RATING, AVG (IMDB_SCORE), MAX (IMDB_SCORE), MIN (IMDB_SCORE)
36
+FROM MOVIES
37
+GROUP BY RATING;
38
+
39
+SELECT RATING, AVG (IMDB_SCORE), MAX (IMDB_SCORE), MIN (IMDB_SCORE)
40
+FROM MOVIES
41
+GROUP BY RATING
42
+HAVING COUNT(*) > 1;
43
+
44
+DELETE FROM MOVIES
45
+WHERE RATING = 'R';