You are on page 1of 5

DEPARTMENT OF COMPUTER SCIENCE

SPRING SEMESTER 2016

RELATIONAL DATABASE SYSTEM

ASSIGNMENT #2
1. Write a SQL statement to give all employees a 25% pay increase,
commit your changes and view the table.

update emp set sal = sal * 0.25;


Commit;
Select * From Emp;

Sql> Update Emp Set Sal = Sal *0.25;

14 Rows Updated.

Sql> Select * From Emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM


---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 200
20

7499 ALLEN SALESMAN 7698 20-FEB-81 400 300


30

7521 WARD SALESMAN 7698 22-FEB-81 312.5 500


30

EMPNO ENAME JOB MGR HIREDATE SAL COMM


---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 743.75
20

7654 MARTIN SALESMAN 7698 28-SEP-81 312.5 1400


30

7698 BLAKE MANAGER 7839 01-MAY-81 712.5


30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 612.5
10

7788 SCOTT ANALYST 7566 19-APR-87 750


20

7839 KING PRESIDENT 17-NOV-81 1250


10

EMPNO ENAME JOB MGR HIREDATE SAL COMM


---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 375 0
30

7876 ADAMS CLERK 7788 23-MAY-87 275


20

7900 JAMES CLERK 7698 03-DEC-81 237.5


30

2. Give all employees who work in NEW YORK an additional 5%


pay increase, rollback your changes and view the table.
Select Ename, Sal*0.5 From Emp Where Deptno = ( Select Deptno From Dept
Where Loc = 'NEW YORK');

3. Create a new department called I.T located in ENGLAND.


Insert Into Dept Values ( 50, 'I.T', 'ENGLAND');
4. Remove the department you created in question 3.
Delete From Dept Where Deptno = 50;
5. Create a sequence called EMPINFO_SEQ, start it at 10 and
increment it by 1.
Create Sequence EMPINFO_SEQ Start With 10 Increment By 1;

6. Create a new table called EMPLOYEE_INFO, using the following table as


a guide:
Column Name Datatype & Size
INFO_ID NUMBER
EMPNO NUMBER
INFO_DATE DATE
INFO VARCHAR2 80

Create Table EMPLOYEE_INFO (


Info_Id Number(10) Not Null,
Emp_Id Number(10) Not Null,
Info_Date Date,
Info Varchar2(80));

7. Insert a row into the new table, set INFO_ID to be the next value
from the sequence you created, set EMPNO to a valid employee
number, INFO_DATE to today’s date and enter some text into
INFO.
Insert Into EMPLOYEE_INFO Values( EMPINFO_SEQ.Nextval,101,'13-May-
16','Manager');

8. Create a synonym called einfo for your new table.


Connect System/Abc.123
Create Synonym Einfo For Scott.Employee_Info;
Select * From Einfo;
9. Select all rows from your new table using the synonym;
SQL> select * from einfo;
INFO_ID EMPNO INFO_DATE INFO
---------- ---------- ---------
--------------------------------------------------------------------------------
11 7902 05-MAY-16 STATUS SATISTFIED

10. Remove the new synonym and table.

SYNONYM DROPPED.

You might also like