From bcedc4affe6e1c75695a76da7921a793f66a3c85 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Mon, 25 Nov 2019 19:47:29 -0500 Subject: [PATCH 01/21] create database --- .idea/.gitignore | 3 +++ .idea/SQL.BuildAndDestroy.iml | 9 +++++++++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ answers/exercise1.sql | 1 + 6 files changed, 33 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/SQL.BuildAndDestroy.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..0e40fe8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ + +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/SQL.BuildAndDestroy.iml b/.idea/SQL.BuildAndDestroy.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/SQL.BuildAndDestroy.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..28a804d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9bfba77 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/answers/exercise1.sql b/answers/exercise1.sql index e69de29..07c2318 100644 --- a/answers/exercise1.sql +++ b/answers/exercise1.sql @@ -0,0 +1 @@ +CREATE DATABASE myNewDB; \ No newline at end of file From 0ec3c24b4f06d3cd3c9d7939d15bff83366f0913 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Mon, 25 Nov 2019 19:48:45 -0500 Subject: [PATCH 02/21] gitignore --- .idea/.gitignore | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.idea/.gitignore b/.idea/.gitignore index 0e40fe8..f8a1927 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,3 +1,16 @@ # Default ignored files -/workspace.xml \ No newline at end of file +/workspace.xml + +.idea/* +*.iml +*/target/* +*/target/** +.classpath +.project +.settings/ + +# Apple files +*.DS_Store +.AppleDouble +.LSOverride \ No newline at end of file From 04a9a41acd63a402551d91ff16b5311e5f4f9559 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Mon, 25 Nov 2019 19:50:31 -0500 Subject: [PATCH 03/21] drop db --- .idea/inspectionProfiles/Project_Default.xml | 7 +++++++ answers/exercise2.sql | 1 + 2 files changed, 8 insertions(+) create mode 100644 .idea/inspectionProfiles/Project_Default.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..be4b286 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/answers/exercise2.sql b/answers/exercise2.sql index e69de29..e7487f3 100644 --- a/answers/exercise2.sql +++ b/answers/exercise2.sql @@ -0,0 +1 @@ +DROP DATABASE myNewDB; \ No newline at end of file From 35dc8094e91b155aa4401cbe0fc83bb348232bd6 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Mon, 25 Nov 2019 19:53:20 -0500 Subject: [PATCH 04/21] create table --- answers/exercise3.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/answers/exercise3.sql b/answers/exercise3.sql index e69de29..adba91f 100644 --- a/answers/exercise3.sql +++ b/answers/exercise3.sql @@ -0,0 +1,7 @@ +CREATE TABLE Users{ + UserID int, + LastName varchar(255), + FirstName varchar(255), + Adress varchar(255), + City varchar(255) +}; \ No newline at end of file From 01ab0dcc8c25580f5ab6eb300db6eca56fe01205 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Mon, 25 Nov 2019 19:54:31 -0500 Subject: [PATCH 05/21] drop table --- answers/exercise4.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise4.sql b/answers/exercise4.sql index e69de29..fe6a7f5 100644 --- a/answers/exercise4.sql +++ b/answers/exercise4.sql @@ -0,0 +1 @@ +DROP TABLE Users; \ No newline at end of file From 6280c2d706333f19c4982c629f3bd4e532dce3c6 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Mon, 25 Nov 2019 19:56:11 -0500 Subject: [PATCH 06/21] truncate --- answers/exercise5.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise5.sql b/answers/exercise5.sql index e69de29..12321ad 100644 --- a/answers/exercise5.sql +++ b/answers/exercise5.sql @@ -0,0 +1 @@ +TRUNCATE TABLE Users; \ No newline at end of file From c5f48269cec3be0c7298afc9874a4950f054e0cd Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 08:42:24 -0500 Subject: [PATCH 07/21] add column --- answers/exercise6.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise6.sql b/answers/exercise6.sql index e69de29..9782ded 100644 --- a/answers/exercise6.sql +++ b/answers/exercise6.sql @@ -0,0 +1 @@ +ALTER TABLE Users ADD Birthday DATE; \ No newline at end of file From 1bcebad2900ce5644775352a4ff03f3273388bb6 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 08:52:23 -0500 Subject: [PATCH 08/21] drop column --- answers/exercise7.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise7.sql b/answers/exercise7.sql index e69de29..550ea79 100644 --- a/answers/exercise7.sql +++ b/answers/exercise7.sql @@ -0,0 +1 @@ +ALTER TABLE Users DROP COLUMN Birthday; \ No newline at end of file From aba9ea615420676323085de710f9a3972487a805 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 08:58:45 -0500 Subject: [PATCH 09/21] insert --- answers/exercise8.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/answers/exercise8.sql b/answers/exercise8.sql index e69de29..dde112e 100644 --- a/answers/exercise8.sql +++ b/answers/exercise8.sql @@ -0,0 +1,3 @@ +INSERT INTO Students +(StudentName, Address, City, PostalCode, Country) +VALUES ("Jane Doe", "57 Union St", "Glasgow", "G13RB", "Scotland"); \ No newline at end of file From 8c0d4ad9d4a9b4747eb7c4b6a2ca5b99b8500c89 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:04:24 -0500 Subject: [PATCH 10/21] NOT --- answers/exercise9.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise9.sql b/answers/exercise9.sql index e69de29..6292c6c 100644 --- a/answers/exercise9.sql +++ b/answers/exercise9.sql @@ -0,0 +1 @@ +SELECT * FROM Students WHERE NOT City = 'Philadelphia'; \ No newline at end of file From 27ecbdc1b1548e2b3825f1c683c7f6dbcaf4026b Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:05:53 -0500 Subject: [PATCH 11/21] matching condition --- answers/exercise10.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise10.sql b/answers/exercise10.sql index e69de29..1fa5e76 100644 --- a/answers/exercise10.sql +++ b/answers/exercise10.sql @@ -0,0 +1 @@ +SELECT * FROM Students WHERE City IN ('Philadelphia', 'Trenton') \ No newline at end of file From 91c3d29760f9fcd013569096838719ef1f5ffbfe Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:07:05 -0500 Subject: [PATCH 12/21] order by asc --- answers/exercise11.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise11.sql b/answers/exercise11.sql index e69de29..3d56eb0 100644 --- a/answers/exercise11.sql +++ b/answers/exercise11.sql @@ -0,0 +1 @@ +SELECT * FROM Students ORDER BY City; \ No newline at end of file From ee651b4e726ca91877e14e39cbea7c1e22e7ef2c Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:20:52 -0500 Subject: [PATCH 13/21] order desc --- answers/exercise12.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise12.sql b/answers/exercise12.sql index e69de29..387247f 100644 --- a/answers/exercise12.sql +++ b/answers/exercise12.sql @@ -0,0 +1 @@ +SELECT * FROM Students ORDER BY City DESC; \ No newline at end of file From 2d2e06c14ea9e3e28adf509d6c06fbec0d381f42 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:24:13 -0500 Subject: [PATCH 14/21] order by multiple --- answers/exercise13.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise13.sql b/answers/exercise13.sql index e69de29..795abb6 100644 --- a/answers/exercise13.sql +++ b/answers/exercise13.sql @@ -0,0 +1 @@ +SELECT * FROM Students ORDER BY Country, City; \ No newline at end of file From 85889e3e8559cf29f83786b0f715ca4528ac4804 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:38:28 -0500 Subject: [PATCH 15/21] not null --- answers/exercise14.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise14.sql b/answers/exercise14.sql index e69de29..e562e34 100644 --- a/answers/exercise14.sql +++ b/answers/exercise14.sql @@ -0,0 +1 @@ +SELECT * FROM Students WHERE PostalCode IS NULL; \ No newline at end of file From 5f5d9592dabfb089ea23545d1ffcd698b9acef7d Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:39:08 -0500 Subject: [PATCH 16/21] not null --- answers/exercise15.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise15.sql b/answers/exercise15.sql index e69de29..f0ff0df 100644 --- a/answers/exercise15.sql +++ b/answers/exercise15.sql @@ -0,0 +1 @@ +SELECT * FROM Students WHERE PostalCode IS NOT NULL; \ No newline at end of file From 43e43a8f18b89d8d97c503b6b9b8091c00633615 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:41:12 -0500 Subject: [PATCH 17/21] update city --- answers/exercise16.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise16.sql b/answers/exercise16.sql index e69de29..8abbc29 100644 --- a/answers/exercise16.sql +++ b/answers/exercise16.sql @@ -0,0 +1 @@ +UPDATE Students SET City ='Edinburgh'; \ No newline at end of file From 58303b039c0d9e5d7a96f33f28dd30bfeaa1ce85 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:42:30 -0500 Subject: [PATCH 18/21] update column where --- answers/exercise17.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise17.sql b/answers/exercise17.sql index e69de29..475bb10 100644 --- a/answers/exercise17.sql +++ b/answers/exercise17.sql @@ -0,0 +1 @@ +UPDATE Students SET City = 'Edinburgh' WHERE Country = 'Scotland'; \ No newline at end of file From b4cd3deb27482c3bb95a31f05ce38f44ec8d1531 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:45:17 -0500 Subject: [PATCH 19/21] update multiple col --- answers/exercise18.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise18.sql b/answers/exercise18.sql index e69de29..2524ddc 100644 --- a/answers/exercise18.sql +++ b/answers/exercise18.sql @@ -0,0 +1 @@ +UPDATE Students SET City = 'Edinburgh', Country = 'Scotland' WHERE ID = 35; \ No newline at end of file From deaa277325942c2f246d223af4d069a04f85f7c5 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:49:16 -0500 Subject: [PATCH 20/21] delete where --- answers/exercise19.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise19.sql b/answers/exercise19.sql index e69de29..2cdd0fd 100644 --- a/answers/exercise19.sql +++ b/answers/exercise19.sql @@ -0,0 +1 @@ +DELETE FROM Students WHERE Country = 'Scotland'; \ No newline at end of file From 1436ad0b0c88cdd64b975c9cdcb682ac9ab38017 Mon Sep 17 00:00:00 2001 From: jeanvalentin51 Date: Tue, 26 Nov 2019 09:50:43 -0500 Subject: [PATCH 21/21] delete all --- answers/exercise20.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/answers/exercise20.sql b/answers/exercise20.sql index e69de29..c829a24 100644 --- a/answers/exercise20.sql +++ b/answers/exercise20.sql @@ -0,0 +1,3 @@ +DELETE FROM Students; + +// more safety net compared to TRUNCATE; identiy keys are not reset \ No newline at end of file