From ecd57ea0ae4296383712965747d8f514ffc74600 Mon Sep 17 00:00:00 2001 From: Dee Date: Thu, 29 Jul 2021 18:03:58 -0400 Subject: [PATCH 01/11] maybe added answers --- answers/exercise1.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise1.sql b/answers/exercise1.sql index e69de29..5a67f00 100644 --- a/answers/exercise1.sql +++ b/answers/exercise1.sql @@ -0,0 +1 @@ +CREATE SCHEMA MyNewDB; From a3bc4d75dad12c13ac65c16f2130955ba48a27e2 Mon Sep 17 00:00:00 2001 From: Dee Date: Thu, 29 Jul 2021 21:04:35 -0400 Subject: [PATCH 02/11] delete database --- answers/exercise2.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/answers/exercise2.sql b/answers/exercise2.sql index e69de29..b9949a1 100644 --- a/answers/exercise2.sql +++ b/answers/exercise2.sql @@ -0,0 +1 @@ +DELETE FROM myNewDB; From bf8fa359b097fd50331f80fad72bf0a06a0e0456 Mon Sep 17 00:00:00 2001 From: Dee Date: Thu, 29 Jul 2021 21:12:32 -0400 Subject: [PATCH 03/11] corrected delete database --- answers/exercise2.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/answers/exercise2.sql b/answers/exercise2.sql index b9949a1..982b807 100644 --- a/answers/exercise2.sql +++ b/answers/exercise2.sql @@ -1 +1 @@ -DELETE FROM myNewDB; +DROP DATABASE myNewDB; From 7f834c442dcb46add1367abed19b636bcc6a91fa Mon Sep 17 00:00:00 2001 From: Dee Date: Thu, 29 Jul 2021 21:23:23 -0400 Subject: [PATCH 04/11] created user table --- answers/exercise3.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/answers/exercise3.sql b/answers/exercise3.sql index e69de29..c156499 100644 --- a/answers/exercise3.sql +++ b/answers/exercise3.sql @@ -0,0 +1,8 @@ +CREATE SCHEMA userDatabase; +USE userDatabase; +CREATE TABLE users +( userID INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, +lastName VARCHAR(255) NOT NULL, +firstName VARCHAR(255) NOT NULL, +address VARCHAR(255) NOT NULL, +city VARCHAR(255) NOT NULL ); From 50edae80a6be6756cf62597aef7775b4b598623f Mon Sep 17 00:00:00 2001 From: Dee Date: Thu, 29 Jul 2021 21:59:44 -0400 Subject: [PATCH 05/11] add, delete, and insert --- answers/exercise4.sql | 2 ++ answers/exercise5.sql | 2 ++ answers/exercise6.sql | 3 +++ answers/exercise7.sql | 1 + answers/exercise8.sql | 2 ++ 5 files changed, 10 insertions(+) diff --git a/answers/exercise4.sql b/answers/exercise4.sql index e69de29..c9961fc 100644 --- a/answers/exercise4.sql +++ b/answers/exercise4.sql @@ -0,0 +1,2 @@ +USE userDatabase; +DROP TABLE Users; diff --git a/answers/exercise5.sql b/answers/exercise5.sql index e69de29..faa8aff 100644 --- a/answers/exercise5.sql +++ b/answers/exercise5.sql @@ -0,0 +1,2 @@ +USE userDatabase; +TRUNCATE TABLE Users; diff --git a/answers/exercise6.sql b/answers/exercise6.sql index e69de29..905e5d8 100644 --- a/answers/exercise6.sql +++ b/answers/exercise6.sql @@ -0,0 +1,3 @@ +USE userDatabase; +ALTER TABLE Users +ADD birthday DATE; diff --git a/answers/exercise7.sql b/answers/exercise7.sql index e69de29..1915d43 100644 --- a/answers/exercise7.sql +++ b/answers/exercise7.sql @@ -0,0 +1 @@ +ALTER TABLE Users DROP COLUMN birthday; diff --git a/answers/exercise8.sql b/answers/exercise8.sql index e69de29..3f2a2df 100644 --- a/answers/exercise8.sql +++ b/answers/exercise8.sql @@ -0,0 +1,2 @@ +INSERT INTO Students (studentName, address, city, postalCode, country) +VALUES ('Jane Doe', '57 Union St', 'Glasgow', 'G13RB', 'Scotland'); From 6887d7d1089e749629df853015b89de6dbfbe2d0 Mon Sep 17 00:00:00 2001 From: Dee Date: Thu, 29 Jul 2021 22:10:29 -0400 Subject: [PATCH 06/11] select students by city --- answers/exercise10.sql | 3 +++ answers/exercise9.sql | 2 ++ 2 files changed, 5 insertions(+) diff --git a/answers/exercise10.sql b/answers/exercise10.sql index e69de29..a5d02e1 100644 --- a/answers/exercise10.sql +++ b/answers/exercise10.sql @@ -0,0 +1,3 @@ +SELECT * FROM Students +WHERE city = 'Philadelphia' +OR city = 'Trenton' ; diff --git a/answers/exercise9.sql b/answers/exercise9.sql index e69de29..5d4e2c5 100644 --- a/answers/exercise9.sql +++ b/answers/exercise9.sql @@ -0,0 +1,2 @@ +SELECT * FROM Students +WHERE city <> 'Philadelphia' ; From c77b0957271eac409f97384f7d1225293a6e22f6 Mon Sep 17 00:00:00 2001 From: Dee Date: Fri, 30 Jul 2021 08:22:52 -0400 Subject: [PATCH 07/11] ordered commands --- answers/exercise11.sql | 1 + answers/exercise12.sql | 1 + answers/exercise13.sql | 2 ++ 3 files changed, 4 insertions(+) diff --git a/answers/exercise11.sql b/answers/exercise11.sql index e69de29..970d496 100644 --- a/answers/exercise11.sql +++ b/answers/exercise11.sql @@ -0,0 +1 @@ +SELECT * FROM Students ORDER BY city; diff --git a/answers/exercise12.sql b/answers/exercise12.sql index e69de29..b328e1b 100644 --- a/answers/exercise12.sql +++ b/answers/exercise12.sql @@ -0,0 +1 @@ +SELECT * FROM Students ORDER BY city DESC; diff --git a/answers/exercise13.sql b/answers/exercise13.sql index e69de29..8a3c585 100644 --- a/answers/exercise13.sql +++ b/answers/exercise13.sql @@ -0,0 +1,2 @@ +SELECT * FROM Students ORDER BY city, country; + From 5d51d3c9286b6ab865c92226bf6f6b234aef7a1e Mon Sep 17 00:00:00 2001 From: Dee Date: Fri, 30 Jul 2021 08:30:19 -0400 Subject: [PATCH 08/11] null values queries --- answers/exercise14.sql | 2 ++ answers/exercise15.sql | 2 ++ 2 files changed, 4 insertions(+) diff --git a/answers/exercise14.sql b/answers/exercise14.sql index e69de29..60ae078 100644 --- a/answers/exercise14.sql +++ b/answers/exercise14.sql @@ -0,0 +1,2 @@ +SELECT * FROM Students +WHERE postalCode IS NULL; diff --git a/answers/exercise15.sql b/answers/exercise15.sql index e69de29..7df0423 100644 --- a/answers/exercise15.sql +++ b/answers/exercise15.sql @@ -0,0 +1,2 @@ +SELECT * FROM Students +WHERE postalCode IS NOT NULL; From f568cf107a3f555a43bcd814ac5adb584ffe3166 Mon Sep 17 00:00:00 2001 From: Dee Date: Fri, 30 Jul 2021 08:42:27 -0400 Subject: [PATCH 09/11] updating records --- answers/exercise16.sql | 2 ++ answers/exercise17.sql | 3 +++ answers/exercise18.sql | 3 +++ 3 files changed, 8 insertions(+) diff --git a/answers/exercise16.sql b/answers/exercise16.sql index e69de29..c52d34a 100644 --- a/answers/exercise16.sql +++ b/answers/exercise16.sql @@ -0,0 +1,2 @@ +UPDATE Students +SET city = 'Edinburgh'; diff --git a/answers/exercise17.sql b/answers/exercise17.sql index e69de29..8b3ad6c 100644 --- a/answers/exercise17.sql +++ b/answers/exercise17.sql @@ -0,0 +1,3 @@ +UPDATE Students +SET city = 'Edinburgh' +WHERE city = 'Scotland'; diff --git a/answers/exercise18.sql b/answers/exercise18.sql index e69de29..1500b76 100644 --- a/answers/exercise18.sql +++ b/answers/exercise18.sql @@ -0,0 +1,3 @@ +UPDATE Students +SET city = 'Edingburgh', country = 'Scotland' +WHERE studentId = 35; From aa1928b1e0ab8a0656f2121323a2a1c098a8c2e5 Mon Sep 17 00:00:00 2001 From: Dee Date: Fri, 30 Jul 2021 08:47:26 -0400 Subject: [PATCH 10/11] deleting records --- exercise19.sql | 2 ++ exercise20.sql | 1 + 2 files changed, 3 insertions(+) create mode 100644 exercise19.sql create mode 100644 exercise20.sql diff --git a/exercise19.sql b/exercise19.sql new file mode 100644 index 0000000..b25ab2e --- /dev/null +++ b/exercise19.sql @@ -0,0 +1,2 @@ +DELETE FROM Students +WHERE country = 'Scotland'; diff --git a/exercise20.sql b/exercise20.sql new file mode 100644 index 0000000..e72ad37 --- /dev/null +++ b/exercise20.sql @@ -0,0 +1 @@ +DELETE FROM Students; From c848cccbdc7c4e381f66a53d37db9cdf93a798ab Mon Sep 17 00:00:00 2001 From: Dee Date: Fri, 30 Jul 2021 08:54:29 -0400 Subject: [PATCH 11/11] updating 2 columns with condition --- exercise18.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 exercise18.sql diff --git a/exercise18.sql b/exercise18.sql new file mode 100644 index 0000000..185e830 --- /dev/null +++ b/exercise18.sql @@ -0,0 +1,3 @@ +UPDATE Students +SET city = 'Edinburgh', country = 'Scotland' +WHERE studentId = 35;