You are on page 1of 4

mml@mml-Vostro-3470:~$ sudo mysql

[sudo] password for mml:


Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 13


Server version: 8.0.30-0ubuntu0.20.04.2 (Ubuntu)
Copyright (c) 2000, 2022, 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> create database exp4;


Query OK, 1 row affected (0.01 sec)

mysql> use exp4;


Database changed

mysql> create table student (stud_id int, stud_name varchar(50), sgpa float);

Query OK, 0 rows affected (0.03 sec)

mysql> insert into student (stud_id,stud_name,sgpa) values (1,'Arnav',8.8);


Query OK, 1 row affected (0.01 sec)

mysql> insert into student (stud_id,stud_name,sgpa) values


(2,'Kushal',8.5),(3,'Vikram',9.0),(4,'Sharvari',9.5),(5,'Agastya',7.9);

Query OK, 4 rows affected (0.01 sec)


Records: 4 Duplicates: 0 Warnings: 0

mysql> select *from student;


+---------+-----------+------+
| stud_id | stud_name | sgpa |
+---------+-----------+------+
| 1 | Arnav | 8.8 |

| 2 | Kushal | 8.5 |
| 3 | Vikram | 9 |
| 4 | Sharvari | 9.5 |
| 5 | Agastya | 7.9 |
+---------+-----------+------+

5 rows in set (0.00 sec)

mysql> select *from student where sgpa>8;


+---------+-----------+------+
| stud_id | stud_name | sgpa |

+---------+-----------+------+
| 1 | Arnav | 8.8 |
| 2 | Kushal | 8.5 |
| 3 | Vikram | 9 |
| 4 | Sharvari | 9.5 |

+---------+-----------+------+
4 rows in set (0.01 sec)

mysql> select *from student where stud_name like 'A%';


+---------+-----------+------+

| stud_id | stud_name | sgpa |


+---------+-----------+------+
| 1 | Arnav | 8.8 |
| 5 | Agastya | 7.9 |
+---------+-----------+------+
2 rows in set (0.01 sec)
mysql> select *from student where sgpa between 8 and 9;
+---------+-----------+------+

| stud_id | stud_name | sgpa |


+---------+-----------+------+
| 1 | Arnav | 8.8 |
| 2 | Kushal | 8.5 |
| 3 | Vikram | 9 |

+---------+-----------+------+
3 rows in set (0.00 sec)

mysql> update student set stud_name='Kaivalya' where stud_id=2;


Query OK, 1 row affected (0.01 sec)

Rows matched: 1 Changed: 1 Warnings: 0

mysql> select*from student;


+---------+-----------+------+
| stud_id | stud_name | sgpa |

+---------+-----------+------+
| 1 | Arnav | 8.8 |
| 2 | Kaivalya | 8.5 |
| 3 | Vikram | 9 |
| 4 | Sharvari | 9.5 |

| 5 | Agastya | 7.9 |
+---------+-----------+------+
5 rows in set (0.00 sec)

mysql> delete from student where stud_id=5;


Query OK, 1 row affected (0.01 sec)
mysql> select*from student;
+---------+-----------+------+

| stud_id | stud_name | sgpa |


+---------+-----------+------+
| 1 | Arnav | 8.8 |
| 2 | Kaivalya | 8.5 |
| 3 | Vikram | 9 |

| 4 | Sharvari | 9.5 |
+---------+-----------+------+
4 rows in set (0.00 sec)

You might also like