Skip to content
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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions SQL.BuildAndDestroy.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
14 changes: 14 additions & 0 deletions answers/exercise1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mysql> show databases;
+--------------mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| myNewDB |
| mysql |
| performance_schema |
| sys |
| zipcode |
+--------------------+
6 rows in set (0.06 sec)

10 changes: 10 additions & 0 deletions answers/exercise10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mysql> Select * From Students where City != 'Philadelphia';
+-------------+--------------------+-------------+------------+------------+
| StudentName | Address | City | PostalCode | Country |
+-------------+--------------------+-------------+------------+------------+
| Jane Doe | 57 Union St | Glasgow | G13RB | Scotland |
| Gucci Mane | East Atlanta Santa | Atlanta | 30309 | Georgia |
| Karrauche | Calabases Way | Los Angeles | 90018 | California |
| Asap Rocky | East 112th Street | Manhantan | 10001 | New York |
+-------------+--------------------+-------------+------------+------------+
4 rows in set (0.00 sec)
11 changes: 11 additions & 0 deletions answers/exercise11.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mysql> Select * from Students order by City asc;
+-------------+--------------------+--------------+------------+--------------+
| StudentName | Address | City | PostalCode | Country |
+-------------+--------------------+--------------+------------+--------------+
| Gucci Mane | East Atlanta Santa | Atlanta | 30309 | Georgia |
| Jane Doe | 57 Union St | Glasgow | G13RB | Scotland |
| Karrauche | Calabases Way | Los Angeles | 90018 | California |
| Asap Rocky | East 112th Street | Manhantan | 10001 | New York |
| Meek Mill | South Street | Philadelphia | 19138 | Pennslyvania |
+-------------+--------------------+--------------+------------+--------------+
5 rows in set (0.00 sec)
11 changes: 11 additions & 0 deletions answers/exercise12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mysql> Select * from Students order by City desc;
+-------------+--------------------+--------------+------------+--------------+
| StudentName | Address | City | PostalCode | Country |
+-------------+--------------------+--------------+------------+--------------+
| Meek Mill | South Street | Philadelphia | 19138 | Pennslyvania |
| Asap Rocky | East 112th Street | Manhantan | 10001 | New York |
| Karrauche | Calabases Way | Los Angeles | 90018 | California |
| Jane Doe | 57 Union St | Glasgow | G13RB | Scotland |
| Gucci Mane | East Atlanta Santa | Atlanta | 30309 | Georgia |
+-------------+--------------------+--------------+------------+--------------+
5 rows in set (0.00 sec)
12 changes: 12 additions & 0 deletions answers/exercise13.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mysql> Select * from Students order by Country asc;
+-------------+--------------------+--------------+------------+--------------+
| StudentName | Address | City | PostalCode | Country |
+-------------+--------------------+--------------+------------+--------------+
| Karrauche | Calabases Way | Los Angeles | 90018 | California |
| Gucci Mane | East Atlanta Santa | Atlanta | 30309 | Georgia |
| Asap Rocky | East 112th Street | Manhantan | 10001 | New York |
| Meek Mill | South Street | Philadelphia | 19138 | Pennslyvania |
| Jane Doe | 57 Union St | Glasgow | G13RB | Scotland |
+-------------+--------------------+--------------+------------+--------------+
5 rows in set (0.00 sec)

4 changes: 4 additions & 0 deletions answers/exercise14.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

mysql> Select * from Students where PostalCode = null;
Empty set (0.00 sec)

11 changes: 11 additions & 0 deletions answers/exercise15.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mysql> Select * from Students;
+-------------+--------------------+--------------+------------+--------------+
| StudentName | Address | City | PostalCode | Country |
+-------------+--------------------+--------------+------------+--------------+
| Jane Doe | 57 Union St | Glasgow | G13RB | Scotland |
| Gucci Mane | East Atlanta Santa | Atlanta | 30309 | Georgia |
| Karrauche | Calabases Way | Los Angeles | 90018 | California |
| Asap Rocky | East 112th Street | Manhantan | 10001 | New York |
| Meek Mill | South Street | Philadelphia | 19138 | Pennslyvania |
+-------------+--------------------+--------------+------------+--------------+
5 rows in set (0.00 sec)
3 changes: 3 additions & 0 deletions answers/exercise16.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mysql> Update Students Set City = 'Edinburgh';
Query OK, 5 rows affected (0.00 sec)
Rows matched: 5 Changed: 5 Warnings: 0
3 changes: 3 additions & 0 deletions answers/exercise17.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mysql> Update Students Set City = 'edinburgh' where Country = 'Scotland';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
11 changes: 11 additions & 0 deletions answers/exercise2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| zipcode |
+--------------------+
5 rows in set (0.00 sec)
4 changes: 4 additions & 0 deletions answers/exercise3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mysql> use myNewDB
Database changed
Create table Users(UserID INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, LastName VARCHAR(255), FirstName VARCHAR(255), Address VARCHAR(255), City VARCHAR(255));Query OK, 0 rows affected (0.02 sec)

3 changes: 3 additions & 0 deletions answers/exercise4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
drop table Users;
Query OK, 0 rows affected (0.01 sec)

2 changes: 2 additions & 0 deletions answers/exercise5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mysql> truncate table Users;
Query OK, 0 rows affected (0.01 sec)
19 changes: 19 additions & 0 deletions answers/exercise6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
mysql> Alter Table Users Add column Birthday DATE;
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0



mysql> describe Users;
+-----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+
| UserID | int | NO | PRI | NULL | auto_increment |
| LastName | varchar(255) | YES | | NULL | |
| FirstName | varchar(255) | YES | | NULL | |
| Address | varchar(255) | YES | | NULL | |
| City | varchar(255) | YES | | NULL | |
| Birthday | date | YES | | NULL | |
+-----------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

3 changes: 3 additions & 0 deletions answers/exercise7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mysql> Alter table Users drop column Birthday;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
5 changes: 5 additions & 0 deletions answers/exercise8.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mysql> Insert into Students (StudentName, Address, City, PostalCode, Country) Values ('Jane Doe', '57 Union St', 'Glasgow', 'G13RB', 'Scotland');
Query OK, 1 row affected (0.00 sec)

mysql>

8 changes: 8 additions & 0 deletions answers/exercise9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mysql> Select City from Students where NOT 'Philadelphia';
+---------+
| City |
+---------+
| Glasgow |
+---------+
1 row in set, 1 warning (0.00 sec)