Name: Vinayak Nagar Reg - No.: 21MCA0015 Subject: Database Technology Topic: Assignment-1
Name: Vinayak Nagar Reg - No.: 21MCA0015 Subject: Database Technology Topic: Assignment-1
Name: Vinayak Nagar Reg - No.: 21MCA0015 Subject: Database Technology Topic: Assignment-1
Reg.No.: 21MCA0015
Subject: Database Technology
Topic: Assignment-1
Exercise:1
Q1)Insert the data given above in both employee, department
and project tables.
Employee Table
create table Employee(Fname varchar2(15),Mname char(2),Lname
varchar2(15),SSN char(9),birthday date,Address varchar2(50),sex char(1),Salary
number(7),Sup_SSN char(9),Dept_no number(5));
desc Department;
ALTER TABLE dept MODIFY dno Number(10) PRIMARY KEY NOT NULL;
Project table:
ALTER TABLE project MODIFY pname varchar(15) NOT NULL;
desc cemp;
Q5)Make salary of employee to accept real values.
Alter table cemp modify Salary(7,4);
EXERCISE-3
Operators and Functions
:-
Aim: To understand different operators and types of function in
SQL
Execute the following queries based on the schema specified in
exercise 1
Q1)Find the employee names having salary greater than
Rs.25000.
select Fname,Mname,Lname from Employee where Salary>25000;
Q2)Find the employee names whose salary lies in the range
between 30000 and 70000.
select Fname,Mname,Lname from Employee where Salary between 30000 and
70000;
Q3)Find the employees who have no supervisor.
select Fname,Mname,Lname from Employee where sup_SSN IS NULL;
Q4)Display the bdate of all employee s in the format
‘DDthMonthYYYY’.
select Fname,Birthday from employee;
Q5)Display the employee names whose bdate is on or before
1978.
select Fname,Mname,Lname from Employee where Birthday<'01-JAN-78';
Q6)Display the employee names having ‘salt lake’ in their
address.
select Fname,Mname,Lname,Address from Employee where Address like '%Salt
Lake%';
Q7)Display the department name that starts with ’M’.
select Dname from Dept where Dname like 'M%';
Q8)Display the department names’ that ends with ‘E’.
select Dname from Dept where Dname like '%e';
Q9)Display the names of all the employees having supervisor
with any of the following SSN 554433221, 333445555.
select fname,sup_SSN from employee where sup_SSN
IN(554433221,333445555);
Q10)Display all the department names in upper case and lower
case.
select UPPER(Dname),LOWER(Dname) from Dept;
SELECT count(ssn) FROM employee where d_no =(SELECT d_no FROM dept
where dname='Research');
Q9)List out the employees based on their seniority.
SELECT fname,lname,months_between(sysdate,birthday)/12 FROM employee
order BY months_between(sysdate,birthday)/12 desc;
Q10)List out the employees who works in ‘manufacture’
department group by first name
SELECT fname,lname,ssn FROM employee where d_no=(SELECT d_no FROM dept
where Dname='Manufacture');