0% found this document useful (0 votes)
20 views

Dbms Lab7

This document shows SQL commands being run on a MySQL database to view, add, update, and delete data from the employee table. It also grants and revokes various privileges on the table to a user.

Uploaded by

dpaul.code
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Dbms Lab7

This document shows SQL commands being run on a MySQL database to view, add, update, and delete data from the employee table. It also grants and revokes various privileges on the table to a user.

Uploaded by

dpaul.code
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

mysql> select * from employee;

+--------+-----------+------+----------+-----------+---------+
| emp_no | emp_name | sex | salary | address | dept_no |
+--------+-----------+------+----------+-----------+---------+
| 1 | Raghuveer | M | 15000.00 | Bhilai | 101 |
| 2 | Aquib | M | 14000.00 | Gaya | 101 |
| 3 | Soura | M | 13000.00 | Kolkata | 103 |
| 4 | Amrutha | F | 8200.00 | Qatar | 102 |
| 6 | Nishant | M | 11000.00 | Bhopal | 103 |
| 0 | NULL | NULL | NULL | NULL | NULL |
| 7 | Wasim | F | 25000.00 | Allahabad | 103 |
+--------+-----------+------+----------+-----------+---------+
7 rows in set (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> delete from employee where sex='F';


Query OK, 2 rows affected (0.00 sec)

mysql> select * from employee;


+--------+-----------+------+----------+---------+---------+
| emp_no | emp_name | sex | salary | address | dept_no |
+--------+-----------+------+----------+---------+---------+
| 1 | Raghuveer | M | 15000.00 | Bhilai | 101 |
| 2 | Aquib | M | 14000.00 | Gaya | 101 |
| 3 | Soura | M | 13000.00 | Kolkata | 103 |
| 6 | Nishant | M | 11000.00 | Bhopal | 103 |
| 0 | NULL | NULL | NULL | NULL | NULL |
+--------+-----------+------+----------+---------+---------+
5 rows in set (0.00 sec)

mysql> rollback;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from employee;


+--------+-----------+------+----------+---------+---------+
| emp_no | emp_name | sex | salary | address | dept_no |
+--------+-----------+------+----------+---------+---------+
| 1 | Raghuveer | M | 15000.00 | Bhilai | 101 |
| 2 | Aquib | M | 14000.00 | Gaya | 101 |
| 3 | Soura | M | 13000.00 | Kolkata | 103 |
| 6 | Nishant | M | 11000.00 | Bhopal | 103 |
| 0 | NULL | NULL | NULL | NULL | NULL |
+--------+-----------+------+----------+---------+---------+
5 rows in set (0.00 sec)

mysql> grant all on employee to '206118019'@'localhost';


Query OK, 0 rows affected (0.00 sec)

mysql> show grants for '206118019'@'localhost';


+-----------------------------------------------------------------------+
| Grants for 206118019@localhost |
+-----------------------------------------------------------------------+
| GRANT USAGE ON *.* TO '206118019'@'localhost' |
| GRANT ALL PRIVILEGES ON `veer6`.`employee` TO '206118019'@'localhost' |
+-----------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> revoke all on employee from '206118019'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> show grants for '206118019'@'localhost';


+-----------------------------------------------+
| Grants for 206118019@localhost |
+-----------------------------------------------+
| GRANT USAGE ON *.* TO '206118019'@'localhost' |
+-----------------------------------------------+
1 row in set (0.00 sec)

mysql> grant select,insert on employee to '206118019'@'localhost';


Query OK, 0 rows affected (0.00 sec)

mysql> show grants for '206118019'@'localhost';


+-----------------------------------------------------------------------+
| Grants for 206118019@localhost |
+-----------------------------------------------------------------------+
| GRANT USAGE ON *.* TO '206118019'@'localhost' |
| GRANT SELECT, INSERT ON `veer6`.`employee` TO '206118019'@'localhost' |
+-----------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> revoke select,insert on employee from '206118019'@'localhost';


Query OK, 0 rows affected (0.00 sec)

mysql> show grants for '206118019'@'localhost';


+-----------------------------------------------+
| Grants for 206118019@localhost |
+-----------------------------------------------+
| GRANT USAGE ON *.* TO '206118019'@'localhost' |
+-----------------------------------------------+
1 row in set (0.00 sec)

You might also like