Skip to content

Instantly share code, notes, and snippets.

@krez69
Last active October 2, 2019 10:53
Show Gist options
  • Save krez69/ca2c37540cfabec7f4e5710e37cefd47 to your computer and use it in GitHub Desktop.
Save krez69/ca2c37540cfabec7f4e5710e37cefd47 to your computer and use it in GitHub Desktop.
//Requete d'insertion
mysql> INSERT INTO school (name, country, capacity) VALUES ('Hogwarts School of Witchcraft and Wizardry', 'United Kingdom', 400), ('Ilvermorny School of Witchcraft and Wizardry' , 'USA', 300), ('Koldovstoretz', 'Russia', 125), ('Mahoutokoro School of Magic', 'Japan', 800), ('Uagadou School of Magic', 'Uganda', 350);
mysql> SELECT * FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 550 | France |
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Norway |
| 4 | Hogwarts School of Witchcraft and Wizardry | 400 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoro School of Magic | 800 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
//Requete de modification
mysql> UPDATE school
-> SET country='Sweden'
-> WHERE id=3;
Query OK, 1 row affected (0.20 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 550 | France |
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Sweden |
| 4 | Hogwarts School of Witchcraft and Wizardry | 400 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoro 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;
mysql> SELECT * FROM school;
+----+----------------------------------------------+----------+----------------+
| id | name | capacity | country |
+----+----------------------------------------------+----------+----------------+
| 1 | Beauxbatons Academy of Magic | 550 | France |
| 2 | Castelobruxo | 380 | Brazil |
| 3 | Durmstrang Institute | 570 | Sweden |
| 4 | Hogwarts School of Witchcraft and Wizardry | 400 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
| 7 | Mahoutokoro School of Magic | 700 | Japan |
| 8 | Uagadou School of Magic | 350 | Uganda |
+----+----------------------------------------------+----------+----------------+
//Requete de suppression
mysql> DELETE FROM school
-> WHERE name
-> LIKE '%ic';
Query OK, 3 rows affected (0.79 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 | 400 | United Kingdom |
| 5 | Ilvermorny School of Witchcraft and Wizardry | 300 | USA |
| 6 | Koldovstoretz | 125 | Russia |
+----+----------------------------------------------+----------+----------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment