diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..2c5d264 Binary files /dev/null and b/.DS_Store differ 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..d5dc381 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 diff --git a/answers/exercise11.sql b/answers/exercise11.sql index e69de29..9c0584c 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..10bad7d 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..00f0498 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..b678133 100644 --- a/answers/exercise14.sql +++ b/answers/exercise14.sql @@ -0,0 +1 @@ +SELECT * FROM Students WHERE postal_code IS NULL; \ No newline at end of file diff --git a/answers/exercise15.sql b/answers/exercise15.sql index e69de29..0181208 100644 --- a/answers/exercise15.sql +++ b/answers/exercise15.sql @@ -0,0 +1 @@ +SELECT * FROM Students WHERE postal_code IS NOT NULL; \ No newline at end of file diff --git a/answers/exercise16.sql b/answers/exercise16.sql index e69de29..91ed076 100644 --- a/answers/exercise16.sql +++ b/answers/exercise16.sql @@ -0,0 +1 @@ +UPDATE Students SET city = 'Edinburgh'; \ No newline at end of file diff --git a/answers/exercise17.sql b/answers/exercise17.sql index e69de29..7f0ef88 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 diff --git a/answers/exercise18.sql b/answers/exercise18.sql index e69de29..283f197 100644 --- a/answers/exercise18.sql +++ b/answers/exercise18.sql @@ -0,0 +1 @@ +UPDATE Students SET (city = 'Edinburgh', country = 'Scotland') WHERE student_id = 35; \ No newline at end of file diff --git a/answers/exercise19.sql b/answers/exercise19.sql index e69de29..1a5f094 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..252aadc 100644 --- a/answers/exercise3.sql +++ b/answers/exercise3.sql @@ -0,0 +1,7 @@ +CREATE TABLE Users( + user_id INT PRIMARY KEY, + last_name VARCHAR(255), + first_name VARCHAR(255), + address_ VARCHAR(255), + city VARCHAR(255) +); \ 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..f1ad85c 100644 --- a/answers/exercise5.sql +++ b/answers/exercise5.sql @@ -0,0 +1 @@ +TRUNCATE TABLE myNewDb.Users; \ No newline at end of file diff --git a/answers/exercise6.sql b/answers/exercise6.sql index e69de29..de11c56 100644 --- a/answers/exercise6.sql +++ b/answers/exercise6.sql @@ -0,0 +1,2 @@ +ALTER TABLE Users +ADD Birthday DATE; diff --git a/answers/exercise7.sql b/answers/exercise7.sql index e69de29..9efcc54 100644 --- a/answers/exercise7.sql +++ b/answers/exercise7.sql @@ -0,0 +1,2 @@ +ALTER TABLE Users +DROP COLUMN birthday; \ No newline at end of file diff --git a/answers/exercise8.sql b/answers/exercise8.sql index e69de29..22511c3 100644 --- a/answers/exercise8.sql +++ b/answers/exercise8.sql @@ -0,0 +1,11 @@ +CREATE TABLE Students( + student_id INT PRIMARY KEY, + name_ VARCHAR(255), + address_ VARCHAR(255), + city VARCHAR(255), + postal_code VARCHAR(255), + country VARCHAR(255) +); + +INSERT INTO Students +VALUES('Jane Doe', '57 Union St', 'Glasgow', 'G13RB', 'Scotland'); \ No newline at end of file diff --git a/answers/exercise9.sql b/answers/exercise9.sql index e69de29..8d6bd5e 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