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

VNR VJIET Name of the Experiment: ____________

Name of the Laboratory: ____________ Experiment No.____ Date: _________

Practice DDL and DML commands on a basic table without integrity constraints.
Consider the following schema of:
employee(EMPNO: number(10),
ENAME: varchar2(20),
JOB: varchar2(20),
MGR: number(20),
HIREDATE: date,
SAL: number(20),
COMM:number(10),
DEPTNO: int)
1) Write a SQL query to create a relation employee.

2) Write a SQL query to add new column address to the existing schema.

3) Insert 5 records to the relation employee


VNR VJIET Name of the Experiment: ____________

Name of the Laboratory: ____________ Experiment No.____ Date: __________

4) Update the salary of employee no 103 to 50000.

5) Write a SQL Query to retrieve all the information from employee.

6) Display Unique jobs from employee.


VNR VJIET Name of the Experiment: ____________

Name of the Laboratory: ____________ Experiment No.____ Date: __________

7) Display all the details of john.

8) Write an SQL query to modify the name of column MGR to manager_number.

9) Write a SQL query to display the unique dept with jobs.

FINAL TABLE:

10) List the employees who joined before 1953.

11) Display all the details of employees whose commission is more than their salary.

12) List the empno,ename, daily sal of all employees in asc older of annual sal.
VNR VJIET Name of the Experiment: ____________

Name of the Laboratory: ____________ Experiment No.____ Date: __________

13) List the employees in the asc order of their salaries.

14) List the employees in the asc order of the dept no and desc of jobs.

15) Display all the unique jobs in desc order.

16) List the employees who are either clerks or developers in asc order.

17) List the employees who joined on '01-JAN-50','3-DEC-81','28-MAR-52','12-OCT-81'.

18) List the employees who are working for the deptno 10 or 20.

19) List the employees who are joined in the year 1950.
VNR VJIET Name of the Experiment: ____________

Name of the Laboratory: ____________ Experiment No.____ Date: __________

20)List the employee names those are having 6 characters in their names.

21) List the employee names those are starting with ‘J___’.

22) List the employee names those are having 6 characters and 4th character must R.

23)List the 6 character names starting with E and ending with T.

24) lList the employees those are having sal 4digit number ending with 0.

25) List the employee names those are having a a character set ‘oo’ together.

26) List all the clerks from deptno 10.

27) Select the employees who joined in jan.


VNR VJIET Name of the Experiment: ____________

Name of the Laboratory:


____________________________________ Experiment No.____ Date: __________

Practice DDL and DML commands on a Relational Database, specifying the Integrity
constraints. (Primary Key, Foreign Key, CHECK, NOT NULL) .
Consider the following schema:
emp(eid:int Primary key,
ename:varchar2,
age:int,
salary: number)
works(eid:int foreign key
did:int foreign key
time: varchar2)
dept(did:int Primary key,
dname:varchar2,
budget:number,
manager_id:int)
1. Write a sql statement required to create the above relations and aplly the appropriate
versions of all primary and foreign key constraints.

2. Apply NOT NULL constraint on age and budget.

3. Apply UNIQUE constraint on ename in emp and dname in dept relations.


VNR VJIET Name of the Experiment: ____________

Name of the Laboratory:


____________________________________ Experiment No.____ Date: __________

4. Apply CHECK constraint on salary and salary should be greater than 1000.

5. Apply CHECK constraint on budget and budget should in between 1000 and 50000.
VNR VJIET Name of the Experiment: ____________

Name of the Laboratory:


____________________________________ Experiment No.____ Date: __________

Joins:
Apply joins on schema:
class(class_id,class_name)
class_info(id,address)
Create table class

Insert values into table class

Create table class_info

Insert values into table class_info


VNR VJIET Name of the Experiment: ____________

Name of the Laboratory:


____________________________________ Experiment No.____ Date: __________

1) INNER JOIN

2) NATURAL JOIN

3) LEFT OUTER JOIN

4) RIGHT OUTER JOIN


VNR VJIET Name of the Experiment: ____________

Name of the Laboratory:


____________________________________ Experiment No.____ Date: __________

5) FULL OUTER JOIN

SETS:
Create Table person and person1

Insert values into person and person1


VNR VJIET Name of the Experiment: ____________

Name of the Laboratory:


____________________________________ Experiment No.____ Date: __________

1) UNION

2) UNION ALL
VNR VJIET Name of the Experiment: ____________

Name of the Laboratory:


____________________________________ Experiment No.____ Date: __________

3) INTERSECT

4) MINUS

You might also like