From fe0d59481a033402e4f488c7afcb2ebe389a005b Mon Sep 17 00:00:00 2001 From: MannyMb Date: Thu, 29 Jul 2021 23:40:59 -0400 Subject: [PATCH] fin --- .DS_Store | Bin 0 -> 6148 bytes answers/exercise1.sql | 1 + answers/exercise10.sql | 1 + answers/exercise11.sql | 1 + answers/exercise12.sql | 1 + answers/exercise13.sql | 1 + answers/exercise14.sql | 13 +++++++++++++ answers/exercise15.sql | 1 + answers/exercise16.sql | 5 +++++ answers/exercise17.sql | 1 + answers/exercise18.sql | 1 + answers/exercise19.sql | 1 + answers/exercise2.sql | 1 + answers/exercise20.sql | 1 + answers/exercise3.sql | 10 ++++++++++ answers/exercise4.sql | 1 + answers/exercise5.sql | 1 + answers/exercise6.sql | 3 +++ answers/exercise7.sql | 3 +++ answers/exercise8.sql | 21 +++++++++++++++++++++ answers/exercise9.sql | 1 + 21 files changed, 69 insertions(+) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..22ee19f6196be0d0f47cb4c4093dbd04205459d5 GIT binary patch literal 6148 zcmeHKJ5B>Z41I^I}F zJ(^dn*8pt!wz&cp0OnLje7Kp4pSw=vq&$umH6HMaVKdxs@A^sfafj!g;}*{t@Q!c! z{gx$hhDSW%1w9MzvTz<8uO_b;5CdXB42S_S@EZf(U@7y9L|HK)2E@P@1O9zzRL8Dx zOpH$lO^g7<8QmdV$1Fi??jUxBVGZdX>k7xjOozqItW!5zO(+(( z)88T-)+Ne{0WomMz-ew5-v6(uKg|D!N!p14G4QV#u-R(8TJlNNTPKh6UfZZQRFBzH rUAT@EnrO$wXvf@mJHCvdjBCE;c~>|lMmqhGPSnqU^CA%gf6c%royHrY literal 0 HcmV?d00001 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 diff --git a/answers/exercise10.sql b/answers/exercise10.sql index e69de29..c9729ce 100644 --- a/answers/exercise10.sql +++ b/answers/exercise10.sql @@ -0,0 +1 @@ +SELECT * FROM Students WHERE City IN ('Trenton', 'Philadelphia'); \ No newline at end of file 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 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 diff --git a/answers/exercise13.sql b/answers/exercise13.sql index e69de29..b7a44e7 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 diff --git a/answers/exercise14.sql b/answers/exercise14.sql index e69de29..41cffb6 100644 --- a/answers/exercise14.sql +++ b/answers/exercise14.sql @@ -0,0 +1,13 @@ +INSERT INTO Students( +StudentName, +Address, +City, +Country, +PostalCode) +VALUES( +'Steve-o', +'57 Union St', +'Glasgow', +'Scotland', +NULL); +SELECT * FROM Students WHERE PostalCode IS NULL; \ No newline at end of file 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 diff --git a/answers/exercise16.sql b/answers/exercise16.sql index e69de29..e27f42c 100644 --- a/answers/exercise16.sql +++ b/answers/exercise16.sql @@ -0,0 +1,5 @@ +UPDATE Students SET City = 'Edinburgh'; + +SET SQL_SAFE_UPDATES = 0; + +SELECT * FROM Students; \ No newline at end of file diff --git a/answers/exercise17.sql b/answers/exercise17.sql index e69de29..3ef9098 100644 --- a/answers/exercise17.sql +++ b/answers/exercise17.sql @@ -0,0 +1 @@ +UPDATE Students SET City = 'Edinburgh' AND Country = 'Scotland'; \ No newline at end of file diff --git a/answers/exercise18.sql b/answers/exercise18.sql index e69de29..febf17e 100644 --- a/answers/exercise18.sql +++ b/answers/exercise18.sql @@ -0,0 +1 @@ +UPDATE Students SET City = 'Edinburgh' AND Country = 'Scotland' WHERE ID = 35; \ No newline at end of file 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 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 diff --git a/answers/exercise20.sql b/answers/exercise20.sql index e69de29..5c66fd1 100644 --- a/answers/exercise20.sql +++ b/answers/exercise20.sql @@ -0,0 +1 @@ +DELETE FROM Students; \ No newline at end of file diff --git a/answers/exercise3.sql b/answers/exercise3.sql index e69de29..dca3f6e 100644 --- a/answers/exercise3.sql +++ b/answers/exercise3.sql @@ -0,0 +1,10 @@ +USE myNewDB; + +CREATE TABLE Users( +UserID int, +LastName VARCHAR(255), +FirstName VARCHAR(255), +Address VARCHAR(255), +City VARCHAR(255)); + +DESCRIBE Users; \ No newline at end of file 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 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 diff --git a/answers/exercise6.sql b/answers/exercise6.sql index e69de29..5eeb240 100644 --- a/answers/exercise6.sql +++ b/answers/exercise6.sql @@ -0,0 +1,3 @@ +ALTER TABLE Users +ADD Birthday DATE; +DESCRIBE Users; \ No newline at end of file diff --git a/answers/exercise7.sql b/answers/exercise7.sql index e69de29..ddf5c39 100644 --- a/answers/exercise7.sql +++ b/answers/exercise7.sql @@ -0,0 +1,3 @@ +ALTER TABLE Users +DROP Birthday; +DESCRIBE Users; \ No newline at end of file diff --git a/answers/exercise8.sql b/answers/exercise8.sql index e69de29..c555a6a 100644 --- a/answers/exercise8.sql +++ b/answers/exercise8.sql @@ -0,0 +1,21 @@ +CREATE TABLE Students( +StudentName VARCHAR (255), +Address VARCHAR(255), +City VARCHAR(255), +PostalCode VARCHAR(255), +Country VARCHAR(255)); + +INSERT INTO Students( +StudentName, +Address, +City, +Country, +PostalCode) +VALUES( +'Jane Doe', +'57 Union St', +'Glasgow', +'Scotland', +'G13RB'); + +SELECT * FROM Students; \ No newline at end of file diff --git a/answers/exercise9.sql b/answers/exercise9.sql index e69de29..8e9034d 100644 --- a/answers/exercise9.sql +++ b/answers/exercise9.sql @@ -0,0 +1 @@ +SELECT * FROM Students WHERE City NOT IN ('Philadelphia'); \ No newline at end of file