Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Exercise 1

Objective:

Create a database based on employee and use that database.

Apparatus Required:

MySql Server connection.

Procedure:

create database employees;

use employees;

Result:

The database is successfully created and changed.

Exercise 2

Objective:

1. Create a employee table that contain following constraints.

Empno int(5) primary key, Ename char(20),Gender char(1), Job char(10), Salary
char(10),Comm. int(5), Deptno int(3).

2. Display the structure of the table.


3. Insert 10 records to that table.

Apparatus Required:

MySql Server connection.

Procedure:

create table Employee123(


Empno int(5) primary key,
Ename char(20),
Gender char(1),
Job char(10),
Salary char(10),
Comm. int(5),
Deptno int(3));

Desc Employee;

Insert into Employee123 values(1111,’Aromal M’,’M’,’Clerk’,25000,1000,10);

Insert into Employee123 values(1112,’Amritha Murail’,’F’,’Manager’,35000,3000,20);


Insert into Employee123 values(1113,’Kiran Kumar’,’M’,’Clerk’,25000,1000,30);

Insert into Employee123 values(1114,’Preethy P’,’F’,’Peon’,15000,500,10);

Insert into Employee123 values(1115,’Swathy S’,’F’,’Clerk’,20000,1000,20);

Insert into Employee123 values(1116,’Ammu M’,’F’,’Peon’,10000,500,20);

Insert into Employee123 values(1117,’Jaya S’,’F’,’Manager’,35000,2000,30);

Insert into Employee123 values(1118,’Sreeraj S’,’M’,’Peon’,15000,1000,10);

Insert into Employee123 values(1119,’Adithya S,’M’,’Manager’,25000,2000,20);

Insert into Employee123 values(1120,’Hiran H’,’M’,’Clerk’,25000,2000,15);

Result:

The table is create successfully created and add 10 records to that table.

Exercise 3

Objective:

1. To display all the contents of Employee table.


2. To display Empno. Ename, Job, Salary of the table.

Apparatus Required:

MySql Server connection.

Procedure:

select *from Employee123;

select Empno,Ename,Job,Salary from Employee123;

Result:

The table is successfully displayed

Exercise 4

Objective:

To Execute the alter methods( add,modify,drop,rename).

1. To add an another column, the column name as Emailid varchar(20).


2. To modify the size of gender column
3. To delete the Emailid column
4. To rename the table into”Employeelist” and rename column Ename to Empname.
Apparatus Required:

MySql Server connection.

Procedure:

1. alter table Employee123 add Emailid varchar(20);


2. alter table Employee123 modify column gender char(6);
3. alter table Employee123 drop column Emailid;
4. alter table Employee123 rename to Employeelist;
alter table Employeelist rename column Ename to Empname;

Result:

The alter is successfully executed.

Exercise 5

Objective:

1. To change the job of Employee ‘Kiran Kumar’ to Manager.


2. To delete the fourth employee from the employeelist table.

Apparatus Required:

MySql Server connection.

Procedure:

1. Update Employeeslist set job='Manager' where Empname='Kiran Kumar';


2. Delete from Employeelist where Empno=1114;

Result:

Successfully updated job and delete the employee 1114.

Exercise 6

Objective:

To Execute Relational and Logical Operator

1. Display the details of employees who have salary greater than 20000.
2. Display the name of the clerk employees , salary greater than 24000.
3. List the employees who work as Peon or Manager.
4. List the names of candidate who are not in Deptno 10.

Apparatus Required:

MySql Server connection.


Procedure:

1. select *from Employeelist where salary>20000;


2. select *from Employeelist where job='clerk' and salary>24000;
3. select *from Employeelist where job='peon' or job='manager';
4. select *from Employeelist where not deptno=10;

Result:

The relational and logical operator is successfully executed.

Exercise 7

Objective:

To execute LIKE, IN/NOT IN, BETWEEN operators.

1. Display details of employees whose name end with ‘R’.


2. Display the details of employee who are working in Deptno 10 and 30.
3. Display the details of employee having slary within the range 20000 and 40000.

Apparatus Required:

MySql Server connection.

Procedure:

1. select *from Employeelist where empname like '%r';


2. select *from Employeelist where deptno in(10,30);
3. select *from Employeelist where salary between 20000 and 40000;

Result:

The like,in/not in and between operator is successfully executed.

Exercise 8

Objective:

1. sort the table in ascensing order based on empname column


2. Find the sum of salary
3. Find the avg of comm.
4. To find the number of candidate in the table.
5. Find the maximum salary of clerk employees
6. Find minimum salary of employees who have in the deptno 20.

Apparatus Required:

MySql Server connection.

Procedure:

1. select Empno,Empname from Employeelist order by Empname ASC;


2. select sum(salary) as "sum of salary" from Employeelist;
3. select avg(salary) as "Avg of salary" from Employeelist;
4. select count(*) as "No of Employees" from Employeelist;
5. select max(salary) as "max of Employees" from Employeelist where job='clerk';
6. select min(salary) as "min of Employees" from Employeelist where deptno=20;

Result:

The function is successfully executed.

You might also like