Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wizarding schools BY ALI(L.A)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydata |
| mysql |
| performance_schema |
| sys |
| wild_db_quest |
+--------------------+
6 rows in set (0.00 sec)
mysql> USE wild_db_quest;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> SHOW TABLES;
+-------------------------+
| Tables_in_wild_db_quest |
+-------------------------+
| school |
| wizard |
+-------------------------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM wizard;
+----+-----------+------------+------------+-------------+-------------------------------------------------------------+-----------+
| id | firstname | lastname | birthday | birth_place | biography | is_muggle |
+----+-----------+------------+------------+-------------+-------------------------------------------------------------+-----------+
| 1 | harry | potter | 1980-07-31 | london | | 0 |
| 2 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
| 3 | lily | potter | 1960-01-30 | | mother of Harry Potter | 0 |
| 4 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 |
| 5 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 |
| 6 | fred | weasley | 1978-04-01 | | | 0 |
| 7 | george | weasley | 1978-04-01 | | | 0 |
| 8 | arthur | weasley | 1950-02-06 | | | 0 |
| 9 | molly | weasley | 1949-01-01 | | | 0 |
| 10 | drago | malefoy | 1980-06-05 | | | 0 |
| 11 | albus | dumbledore | 1881-07-01 | | | 0 |
| 12 | severus | rogue | 1960-01-09 | | | 0 |
| 13 | tom | jédusor | 1926-12-31 | | Celui-Dont-On-Ne-Doit-Pas-Prononcer-Le-Nom alias Voldermort | 0 |
| 14 | dudley | dursley | 1980-06-23 | | Cousin d'Harry | 1 |
+----+-----------+------------+------------+-------------+-------------------------------------------------------------+-----------+
14 rows in set (0.00 sec)
mysql> SELECT * FROM school;
Empty set (0.00 sec)
mysql> DESC school;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(100) | NO | | NULL | |
| capacity | int(11) | YES | | NULL | |
| country | varchar(255) | NO | | NULL | |
+----------+--------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
mysql> INSERT INTO school (name,country,capacity)VALUES("Beauxbatons Academy of Magic","France",500),
-> ("Castelobruxo","Brazil",380),
-> ("Durmstrang Institute", "Norway",570),
-> ("Hogwarts School of witchcraft and wizardry","United Kingdom",450),
-> ("Ilvermorny School of Witchcraft and Wizardry","USA",300),
-> ("Koldovstoretz", "Russia" 125),
-> ("Mahoutokoto School of Magic", "Japan",800),
-> ("Uagadou School of Magic", "Uganda", 350);
mysql> INSERT INTO school (name,country,capacity)VALUES("Beauxbatons Academy of Magic","France",500), ("Castelobruxo","Brazil",380), ("Durmstrang Institute", "Norway",570), ("Hogwarts School of witchcraft and wizardry","United Kingdom",450), ("Ilvermorny School of Witchcraft and Wizardry","USA",300), ("Koldovstoretz", "Russia",125), ("Mahoutokoto School of Magic", "Japan",800), ("Uagadou School of Magic", "Uganda", 350);
Query OK, 8 rows affected (0.01 sec)
Records: 8 Duplicates: 0 Warnings: 0
mysql> SHOW TABLES;
+-------------------------+
| Tables_in_wild_db_quest |
+-------------------------+
| school |
| wizard |
+-------------------------+
2 rows in set (0.00 sec)
mysql> SELECT*FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 500 | France |
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Norway |
| 4 | Hogwarts School of witchcraft and wizardry | 450 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoto School of Magic | 800 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0.00 sec)
mysql> UPDATE school
-> SET country = Sweden
-> WHERE name = "Durmstrang Institute";
ERROR 1054 (42S22): Unknown column 'Sweden' in 'field list'
mysql> UPDATE school SET country = "Sweden" WHERE name = "Durmstrang Institute";
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 500 | France |
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Sweden |
| 4 | Hogwarts School of witchcraft and wizardry | 450 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoto School of Magic | 800 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0.00 sec)
mysql> UPDATE school SET capacity = 700 WHERE id = 7;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 500 | France |
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Sweden |
| 4 | Hogwarts School of witchcraft and wizardry | 450 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoto School of Magic | 700 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
8 rows in set (0.00 sec)
mysql> DELETE FROM school WHERE name LIKE "%Magic%";
Query OK, 3 rows affected (0.02 sec)
mysql> SELECT * FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Sweden |
| 4 | Hogwarts School of witchcraft and wizardry | 450 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
+----+----------------------------------------------+----------+----------------+
5 rows in set (0.00 sec)
mysql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.