0% found this document useful (0 votes)
31 views4 pages

New 2

Uploaded by

mehedi.ibne.musa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views4 pages

New 2

Uploaded by

mehedi.ibne.musa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Lab Practical No.

1
Question:
⦁ (Exercise on retrieving records from the table) EMPLOYEES (Employee_Id, First_Name,
Last_Name, Email, Phone_Number, Hire_Date, Job_Id, Salary, Commission_Pct, Manager_Id,
Department_Id)
( a) Find out the employee id, names, salaries of all the employees
( b) List out the employees who works under manager 100
( c) Find the names of the employees who have a salary greater than or equal to 4800
( d) List out the employees whose last name is ‘AUSTIN’
( e) Find the names of the employees who works in departments 60,70 and 80
( f ) Display the unique Manager_Id

Employees table:

⦁ create an employee’s table with the following fields:


(Emp_id,First_name,Last_name,Phone_No,Hire_date,Job_id,Emp_Salary,Comission_Pct,manager_id,
Department_id)

Query:
create table Employees (Emp_id NUMBER(6),First_name CHAR(25),Last_name
CHAR(20),Phone_No NUMBER(12),Hire_date DATE,Job_Id NUMBER(5),Emp_Salary
NUMBER(7),Comission_Pct NUMBER(5),manager_id NUMBER(5),Department_id NUMBER(5));

⦁ Insert five records into the table employees:


Query:

SQL> insert into employees values(47401,'Rama','Rao',8965324170,'28-


Jan-2003',301,60000,601,100,60);

1 row created.

SQL> insert into employees values(47402,'Ranga','Reddy',7020321450,'23-


Jun-2004',302,56464,602,101,70);

1 row created.

SQL> insert into employees values(47403,'Raja','Shekhar',9848002255,'12-


aug-2004',303,58451,603,103,80);

1 row created.

SQL> insert into employees values(47404,'Ravi',' AUSTIN ',9701811356,'30-


sep-2006',304,36520,604,100,90);

1 row created.

SQL> insert into employees values(47405,'Ranga','Raju',9032553262,'17-


May-2014',305,2568,605,105,60);

1 row created.

SQL> Select * from Employees;

⦁ Display the table Employees :

Query:
sql>select * from employees;

1
a) Find out the employee id, names, salaries of all the employees
Query:
sql>select Emp_id,First_Name,Last_Name,Emp_Salary from employees;

b) List out the employees who works under manager 100


Query:
sql>select * from employees where manager_id=100;

c) Find the names of the employees who have a salary greater than or equal to 4800
Query:
sql>select * from employees where EMP_SALARY>=4800;

d) List out the employees whose last name is ‘AUSTIN’


Query:
sql>select * from employees where Last_Name='AUSTIN ';

e) Find the names of the employees who works in departments 60,70 and 80
Query: sql>select * from employees where DEPARTMENT_ID IN(60,70,80);

f) Display the unique Manager_Id from employees table

Query:
sql>select DISTINCT(MANAGER_ID) from employees;

Lab Practical No: 2


Question:

(Exercise on updating records in table)Create Client_master with the following fields(ClientNO,


Name, Address, City, State, bal_due)
( a ) Insert five records
( b ) Find the names of clients whose bal_due> 5000 .
( c ) Change the bal_due of ClientNO “ C123” to Rs. 5100
( d ) Change the name of Client_master to Client12 .
( e ) Display the bal_due heading as “BALANCE” Client master table:

⦁ create a client master table with attributes


(Client_no,Client_Name,Client_Address,Client_City,Client_State,Balance_Due)

Query:
create table Client_Master(Client_no varchar(6),Client_Name char(25),Client_Address
varchar(25),Client_City varchar(20),Client_State varchar(20),Balance_Due number(20));

⦁ insert five records into the Client_Master

Query:
sql>insert INTO CLIENT_MASTER Values('C123','Ramesh','L B Nagar', 'Hyderabad', 'Telangana',
7000);
sql>insert INTO CLIENT_MASTER Values('C124', 'Suresh', 'Dilsuknagar', 'Hyderabad',
'Telangana',6000);
sql>insert INTO CLIENT_MASTER Values('C125','Vignesh','Saroor nagar', 'Hyderabad',
'Telangana',3500);
sql>insert INTO CLIENT_MASTER Values('C126','Rajiv','A S Rao Nagar','Hyderabad',
'Telangana',4500);
sql>insert INTO CLIENT_MASTER Values('C127','Ranga', 'Vanasthalipuram','Hyderabad',
'Telangana',5478);

⦁ Display Client Master Table

2
Query: sql>select * from Client_Master;

⦁ Find the name of Clients whose balance_due >5000


Query: sql>select Client_Name from Client_Master where Balance_Due>5000;

c) Change the bal_due of ClientNO “ C123” to Rs. 5100

Query: sql>update Client_Master set Balance_Due=5100 where Client_No='C123';

d ) Change the name of Client_master to Client12 .


Query: sql>rename Client_Master to Client12;

e ) Display the bal_due heading as “BALANCE” Client master table:


Query: sql> select Client_No, Balance_Due Balance from Client_Master

Lab Practical No: 3


Question:

Rollback and Commit commands


Create Teacher table with the following fields(Name, DeptNo, Date of joining, DeptName,
Location, Salary)
( a ) Insert five records
( b ) Give Increment of 25% salary for Mathematics Department .
( c ) Perform Rollback command
( d ) Give Increment of 15% salary for Commerce Department
( e ) Perform commit command

Create Teacher table with the following fields(Id,Name, DeptNo, Date of joining, DeptName,
Location, Salary)

Query :

SQL> create table teacher(Id number(2) primary key, name varchar2(20) not null, Deptno number(2)
not null, Deptname varchar2(20) not null, joinDate date not null, location varchar2(20) not null, salary
number(10,2) not null);

( a ) Insert five records

SQL> insert into teacher values(10,'kiran',4,'computer science', '03-Jun-2003', 'hyderabad', 50000);


SQL> insert into teacher values(11,'ramu',5,'mathematics', '13-Jul-2008', 'hyderabad', 40000);
SQL> insert into teacher values(12,'raju',6,'commerce', '23-Dec-2005', 'abids', 30000);
SQL> insert into teacher values(13,'manirathnam',6,'commerce', '18-Dec-2006', 'abids', 30000);
SQL> insert into teacher values(14,'sita',6,'commerce', '28-Aug-2016', 'kingkoti', 23000);

( b ) Give Increment of 25% salary for Mathematics Department .

Sql> update teacher set salary= salary+(salary * 0.25) where Deptname= ‘mathematics';

( c ) Perform Rollback command


Sql>rollback;

( d ) Give Increment of 15% salary for Commerce Department


Sql> update teacher set salary= salary+(salary * 0.15) where Deptname= ‘commerce';

( e ) Perform commit command

3
Sql>commit;

You might also like