diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ad039c6 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SQL.BuildAndDestroy.iml b/SQL.BuildAndDestroy.iml new file mode 100644 index 0000000..8021953 --- /dev/null +++ b/SQL.BuildAndDestroy.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/answers/exercise1.sql b/answers/exercise1.sql index e69de29..46ea612 100644 --- a/answers/exercise1.sql +++ b/answers/exercise1.sql @@ -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) + diff --git a/answers/exercise10.sql b/answers/exercise10.sql index e69de29..4c62d03 100644 --- a/answers/exercise10.sql +++ b/answers/exercise10.sql @@ -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) diff --git a/answers/exercise11.sql b/answers/exercise11.sql index e69de29..e3ce029 100644 --- a/answers/exercise11.sql +++ b/answers/exercise11.sql @@ -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) diff --git a/answers/exercise12.sql b/answers/exercise12.sql index e69de29..f271342 100644 --- a/answers/exercise12.sql +++ b/answers/exercise12.sql @@ -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) diff --git a/answers/exercise13.sql b/answers/exercise13.sql index e69de29..91d93b2 100644 --- a/answers/exercise13.sql +++ b/answers/exercise13.sql @@ -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) + diff --git a/answers/exercise14.sql b/answers/exercise14.sql index e69de29..2c3fd8b 100644 --- a/answers/exercise14.sql +++ b/answers/exercise14.sql @@ -0,0 +1,4 @@ + +mysql> Select * from Students where PostalCode = null; +Empty set (0.00 sec) + diff --git a/answers/exercise15.sql b/answers/exercise15.sql index e69de29..827d56c 100644 --- a/answers/exercise15.sql +++ b/answers/exercise15.sql @@ -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) diff --git a/answers/exercise16.sql b/answers/exercise16.sql index e69de29..df58f0f 100644 --- a/answers/exercise16.sql +++ b/answers/exercise16.sql @@ -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 diff --git a/answers/exercise17.sql b/answers/exercise17.sql index e69de29..ca0fe78 100644 --- a/answers/exercise17.sql +++ b/answers/exercise17.sql @@ -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 diff --git a/answers/exercise2.sql b/answers/exercise2.sql index e69de29..d291972 100644 --- a/answers/exercise2.sql +++ b/answers/exercise2.sql @@ -0,0 +1,11 @@ +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| information_schema | +| mysql | +| performance_schema | +| sys | +| zipcode | ++--------------------+ +5 rows in set (0.00 sec) diff --git a/answers/exercise3.sql b/answers/exercise3.sql index e69de29..b80317f 100644 --- a/answers/exercise3.sql +++ b/answers/exercise3.sql @@ -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) + diff --git a/answers/exercise4.sql b/answers/exercise4.sql index e69de29..bb4cdd4 100644 --- a/answers/exercise4.sql +++ b/answers/exercise4.sql @@ -0,0 +1,3 @@ +drop table Users; +Query OK, 0 rows affected (0.01 sec) + diff --git a/answers/exercise5.sql b/answers/exercise5.sql index e69de29..87a4880 100644 --- a/answers/exercise5.sql +++ b/answers/exercise5.sql @@ -0,0 +1,2 @@ +mysql> truncate table Users; +Query OK, 0 rows affected (0.01 sec) diff --git a/answers/exercise6.sql b/answers/exercise6.sql index e69de29..d6d8130 100644 --- a/answers/exercise6.sql +++ b/answers/exercise6.sql @@ -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) + diff --git a/answers/exercise7.sql b/answers/exercise7.sql index e69de29..8aeaba8 100644 --- a/answers/exercise7.sql +++ b/answers/exercise7.sql @@ -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 \ No newline at end of file diff --git a/answers/exercise8.sql b/answers/exercise8.sql index e69de29..6d6c940 100644 --- a/answers/exercise8.sql +++ b/answers/exercise8.sql @@ -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> + diff --git a/answers/exercise9.sql b/answers/exercise9.sql index e69de29..00dbc68 100644 --- a/answers/exercise9.sql +++ b/answers/exercise9.sql @@ -0,0 +1,8 @@ +mysql> Select City from Students where NOT 'Philadelphia'; ++---------+ +| City | ++---------+ +| Glasgow | ++---------+ +1 row in set, 1 warning (0.00 sec) +