Вы находитесь на странице: 1из 2

Database Lab (Oracle)

Assignment 3

Create the following tables described below:

Table Name: EMP


Column Name Data Type Size Constraints
eno char 2 Primary key & first character must be E
ename Varchar2 10 Not null
City Varchar2 10 Allowed cities are Madras , Bombay , Delhi, Kolkata
Salary number 6
dno Number 2 Foreign key references DEPT table
Join_date date

Table name: DEPT


Column Name Data Type Size Constraints
dno number 2 Primary key
dname Varchar2 15

Table name: PROJECT


Column Name Data Type Size Constraints
pno char 2 Primary key & first character must be P
eno char 2 Primary key & Foreign key references EMP

Insert the following data into corresponding table:

Table Name: PROJECT


pno eno
P1 E1
P2 E3
P1 E5
P2 E1
Express the following queries in SQL.

(1) Display all employees having a as the second letter in their names.
(2) Display employee names for those who joined in the month of june.
(3) Display names of all employees in alphabetic order.
(4) Find the average salary of all employees.
(5) Display employee names and department names of all employees who belong to Madras or
Kolkata or Bombay .
(6) List all the employee names whose basic as greater than 7000 and less than 18000
(7) Display list of all employees in dept no 2
(8) Display the no of employees in each department
(9) List only the names of all other employees who get the same basic as that of employee Tamal
(10) Display the joining date of all employees in dd/mm/yy format
(11) Find all departments which have more than 3 employees.
(12) Find the difference between highest and lowest salary
(13) Display the structure of table EMP.
(14) Display employee no employee name and basic pay for employees with lowest salary
(15) List the names and salary of all employee sorted by salary
(16) Display the list of all employees who were hired during 2002
(17) Display employee name and basic pay for all employees who were engaged with at least one
project.
(18) List no. of projects undertaken in Dept 1
(19) Display the names of all employees who are engaged in 2/more projects
(20) List of all employees who have salary between 2000 and 4000
(21) List the details of all employees in department number 1 & 2.

Вам также может понравиться