Microsoft Windows [Version 10.0.19045.
4842]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Davy I>mysql -u root -p
Enter password: **************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.39 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use School
Database changed
mysql> Create Table Students(
-> :
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ':' at
line 2
mysql> Create Table Teachers(
-> teachers_id INT Primary Key,
-> Name varchar(100),
-> Age INT,
-> Subject varchar(100)
-> );
Query OK, 0 rows affected (2.93 sec)
mysql> show tables;
+------------------+
| Tables_in_school |
+------------------+
| students |
| teachers |
+------------------+
2 rows in set (0.29 sec)
mysql> describe teachers:
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ':' at
line 1
mysql> describe teachers;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| teachers_id | int | NO | PRI | NULL | |
| Name | varchar(100) | YES | | NULL | |
| Age | int | YES | | NULL | |
| Subject | varchar(100) | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+
4 rows in set (0.06 sec)
mysql> insert into teachers value('1','Stephen','-','Physics');
ERROR 1366 (HY000): Incorrect integer value: '-' for column 'Age' at row 1
mysql> insert into teachers value('1','Stephen','0','Physics');
Query OK, 1 row affected (0.32 sec)
mysql> insert into teachers value('2','OKello','00','Maths');
Query OK, 1 row affected (0.60 sec)
mysql> insert into teachers value('3','Christine','00','Chemistry');
Query OK, 1 row affected (0.16 sec)
mysql> insert into teachers value('4','Cliford','00','Comp Science');
Query OK, 1 row affected (0.07 sec)
mysql> insert into teachers value('5','Daniel','00','Biology');
Query OK, 1 row affected (0.72 sec)
mysql> select *from students;
+-------------+---------+------+-------+
| students_id | Name | Age | Grade |
+-------------+---------+------+-------+
| 1 | Davy | 14 | A |
| 3 | Rugero | 15 | D |
| 4 | Kassim | 13 | B |
| 5 | Chris | 15 | B |
| 6 | Aguer | 15 | B |
| 7 | Derrick | 14 | B |
+-------------+---------+------+-------+
6 rows in set (0.02 sec)
mysql> select * from teachers;
+-------------+-----------+------+--------------+
| teachers_id | Name | Age | Subject |
+-------------+-----------+------+--------------+
| 1 | Stephen | 0 | Physics |
| 2 | OKello | 0 | Maths |
| 3 | Christine | 0 | Chemistry |
| 4 | Cliford | 0 | Comp Science |
| 5 | Daniel | 0 | Biology |
+-------------+-----------+------+--------------+
5 rows in set (0.00 sec)
mysql> update teachers set teachers_id='6' where Name='Stephen';
Query OK, 1 row affected (1.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update teachers set teachers_id='7' where Subject='Biology';
Query OK, 1 row affected (0.49 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
mysql> select * from teachers
-> ;
+-------------+-----------+------+--------------+
| teachers_id | Name | Age | Subject |
+-------------+-----------+------+--------------+
| 2 | OKello | 0 | Maths |
| 3 | Christine | 0 | Chemistry |
| 4 | Cliford | 0 | Comp Science |
| 6 | Stephen | 0 | Physics |
| 7 | Daniel | 0 | Biology |
+-------------+-----------+------+--------------+
5 rows in set (0.00 sec)
mysql>
Drob database managerie(deleting databases)
https://pseudocode.deepjain.com/?
code=cmVwZWF0JTBEJTBBaW5wdXQlMjBLYXNzaW0lMEQlMEFpZiUyMGthc3NpbT0xMyUwRCUwQSUyMCUyMC
UyMCUyMG91dHB1dCglMjJjb3JyZWN0LnlvdSUyMGhhdmUlMjBqdXN0JTIwZ3Vlc3NlZCUyMGthc3NpbSdzJ
TIwYWdlLk9VdXV1dXV1aHUlMjIpJTBEJTBBJTIwJTIwJTIwJTIwZWxzZSUyMGlmJTIwa2Fzc2ltJTIwJTNF
MTMlMEQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXQoJ3dyb25nLnlvdSUyMGFyZSUyMGR1bWI
nKSUwRCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGVuZCUyMGlmJTBEJTBBdW50aWwlMjBLYXNzaW09MT
MlMEQlMEElMEQlMEE=