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

its lit #26

Open
wants to merge 1 commit 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
2 changes: 2 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE DATABASE myNewDB;
SHOW DATABASES;
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students WHERE City IN ('Philadelphia' , 'Trenton');
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/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 SQL.BuildAndDestroy/answers/exercise12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students ORDER BY City DESC;
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise13.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students ORDER BY Country, City;
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise14.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students WHERE PostalCode IS NULL;
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise15.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students WHERE PostalCode IS NOT NULL;
3 changes: 3 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise16.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE Students SET City = 'Philadelphia';
SET SQL_SAFE_UPDATES = 0;
SELECT * FROM Students;
2 changes: 2 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise17.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
UPDATE Students SET City = 'Edinburgh' WHERE Country = 'Scotland';
SELECT * FROM Students;
4 changes: 4 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise18.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE Students ADD id INT;
SELECT * FROM Students;
UPDATE Students SET id = 35;
UPDATE Students SET City = 'Edinburgh' AND Country = 'Scotland' WHERE id = 35;
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise19.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM Students WHERE Country = 'Scotland';
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP DATABASE myNewDB;
2 changes: 2 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise20.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DELETE FROM Students;
SELECT * FROM Students;
8 changes: 8 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE DATABASE myNewDB;
USE myNewDB;
CREATE TABLE Users(
UserID int, LastName VARCHAR(255),
FirstName VARCHAR(255), Address VARCHAR(255),
City VARCHAR(255)
);
DESCRIBE Users;
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE Users;
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TRUNCATE TABLE Users;
2 changes: 2 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE Users ADD Birthday DATE;
DESCRIBE Users;
2 changes: 2 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE Users DROP Birthday;
DESCRIBE Users;
21 changes: 21 additions & 0 deletions SQL.BuildAndDestroy/answers/exercise8.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE Students(
StudentName VARCHAR(255),
Address VARCHAR(255),
City VARCHAR(255),
PostalCode VARCHAR(255),
Country VARCHAR(255));
DESCRIBE Students;

INSERT INTO Students(
StudentName,
Address,
City,
PostalCode,
Country)
VALUES(
'New Person',
'23 Mindyabiz Ave',
'Bear',
NULL,
'USA');
SELECT * FROM Students;
1 change: 1 addition & 0 deletions SQL.BuildAndDestroy/answers/exercise9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM Students WHERE NOT City = 'Philadelphia';