diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c57d089 Binary files /dev/null and b/.DS_Store differ diff --git a/answers/exercise1.sql b/answers/exercise1.sql index e69de29..4379763 100644 --- a/answers/exercise1.sql +++ b/answers/exercise1.sql @@ -0,0 +1,5 @@ +CREATE SCHEMA myNewDB; + +or + +CREATE DATABASE myNewDB; \ No newline at end of file diff --git a/answers/exercise10.sql b/answers/exercise10.sql index e69de29..1943da0 100644 --- a/answers/exercise10.sql +++ b/answers/exercise10.sql @@ -0,0 +1,2 @@ +SELECT * FROM Students +WHERE City='Philadelphia' OR City='Trenton' \ 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..c91eb52 100644 --- a/answers/exercise13.sql +++ b/answers/exercise13.sql @@ -0,0 +1 @@ +SELECT * FROM Sctudents ORDER BY Country, City; \ No newline at end of file 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 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..8c5ca8c 100644 --- a/answers/exercise16.sql +++ b/answers/exercise16.sql @@ -0,0 +1 @@ +UPDATE Student SET City = 'Edinburgh'; \ No newline at end of file diff --git a/answers/exercise17.sql b/answers/exercise17.sql index e69de29..64b02d4 100644 --- a/answers/exercise17.sql +++ b/answers/exercise17.sql @@ -0,0 +1 @@ +UPDATE Student SET City = 'Edinburgh' WHERE Country = 'Scotland'; \ No newline at end of file diff --git a/answers/exercise18.sql b/answers/exercise18.sql index e69de29..9f7a77a 100644 --- a/answers/exercise18.sql +++ b/answers/exercise18.sql @@ -0,0 +1 @@ +UPDATE Student SET City = "Edinburgh", Country = "Scotland" WHERE Id = 35; \ No newline at end of file diff --git a/answers/exercise19.sql b/answers/exercise19.sql index e69de29..db0da2b 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..368c3ba 100644 --- a/answers/exercise3.sql +++ b/answers/exercise3.sql @@ -0,0 +1,9 @@ +CREATE TABLE Users +( + UserID INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, + LastName VARCHAR (255), + FirstName VARCHAR (255), + Address VARCHAR (255), + City VARCHAR (255) +); + 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..a061a4f 100644 --- a/answers/exercise6.sql +++ b/answers/exercise6.sql @@ -0,0 +1,2 @@ +ALTER TABLE Users +ADD Birthdays DATE; \ No newline at end of file diff --git a/answers/exercise7.sql b/answers/exercise7.sql index e69de29..3321fbe 100644 --- a/answers/exercise7.sql +++ b/answers/exercise7.sql @@ -0,0 +1,2 @@ +ALTER TABLE Users +DROP COLUMN Birthdays; \ No newline at end of file diff --git a/answers/exercise8.sql b/answers/exercise8.sql index e69de29..abe464d 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"); \ No newline at end of file diff --git a/answers/exercise9.sql b/answers/exercise9.sql index e69de29..d3dcd16 100644 --- a/answers/exercise9.sql +++ b/answers/exercise9.sql @@ -0,0 +1,2 @@ +SELECT * FROM Students +WHERE NOT City='Philadelphia'; \ No newline at end of file