Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built and Obliterated #29

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions answers/exercise1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE SCHEMA MyNewDB;
3 changes: 3 additions & 0 deletions answers/exercise10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * FROM Students
WHERE city = 'Philadelphia'
OR city = 'Trenton' ;
1 change: 1 addition & 0 deletions answers/exercise11.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students ORDER BY city;
1 change: 1 addition & 0 deletions answers/exercise12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students ORDER BY city DESC;
2 changes: 2 additions & 0 deletions answers/exercise13.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT * FROM Students ORDER BY city, country;

2 changes: 2 additions & 0 deletions answers/exercise14.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT * FROM Students
WHERE postalCode IS NULL;
2 changes: 2 additions & 0 deletions answers/exercise15.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT * FROM Students
WHERE postalCode IS NOT NULL;
2 changes: 2 additions & 0 deletions answers/exercise16.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
UPDATE Students
SET city = 'Edinburgh';
3 changes: 3 additions & 0 deletions answers/exercise17.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE Students
SET city = 'Edinburgh'
WHERE city = 'Scotland';
3 changes: 3 additions & 0 deletions answers/exercise18.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE Students
SET city = 'Edingburgh', country = 'Scotland'
WHERE studentId = 35;
1 change: 1 addition & 0 deletions answers/exercise2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP DATABASE myNewDB;
8 changes: 8 additions & 0 deletions answers/exercise3.sql
Original file line number Diff line number Diff line change
@@ -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 );
2 changes: 2 additions & 0 deletions answers/exercise4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
USE userDatabase;
DROP TABLE Users;
2 changes: 2 additions & 0 deletions answers/exercise5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
USE userDatabase;
TRUNCATE TABLE Users;
3 changes: 3 additions & 0 deletions answers/exercise6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
USE userDatabase;
ALTER TABLE Users
ADD birthday DATE;
1 change: 1 addition & 0 deletions answers/exercise7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE Users DROP COLUMN birthday;
2 changes: 2 additions & 0 deletions answers/exercise8.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO Students (studentName, address, city, postalCode, country)
VALUES ('Jane Doe', '57 Union St', 'Glasgow', 'G13RB', 'Scotland');
2 changes: 2 additions & 0 deletions answers/exercise9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT * FROM Students
WHERE city <> 'Philadelphia' ;
3 changes: 3 additions & 0 deletions exercise18.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE Students
SET city = 'Edinburgh', country = 'Scotland'
WHERE studentId = 35;
2 changes: 2 additions & 0 deletions exercise19.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DELETE FROM Students
WHERE country = 'Scotland';
1 change: 1 addition & 0 deletions exercise20.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM Students;