You are on page 1of 3

Computer programming

practical
Assignment – 1
Oracle

Submitted by:-
Name: Mayank Sheth

PRN: 09030122056

Class: B.B.A.-I.T (SEM -4)

Div: ”A”
Table Creation

Query for Table Creation:


Create table emp_56 (eno number(5),ename varchar2(30),job varchar2(20),deptno
number(5),salary number(5),comm number(3),hiredate date);

Question -1 Write query to add Remarks column in EMP table.


Ans - alter table emp_56 add remarks varchar2(50);

Question -2 Write a query to display ename, sal, comm. And total income (sal
+ Comm) in descending order of total income
Ans - select ename, salary, comm, salary+comm"Total_Income" from emp_56

order by "Total_Income" desc;

Question -3 Display the employee name and department number of all


employees in department 10 and 30 in alphabetical order by name.
Ans - select ename, deptno from emp_56 where deptno=10 or deptno=30 order by
ename;

Question -4 Display the employee number, name, salary, and salary increase
by 15 % expressed as whole number.
Ans - select eno, ename, salary, salary+salary*0.15"inc_sal" from emp_56;
Question -5 For each employee display the employee name and calculate the
number of months between today and the date of the employee was hired.
Order your results by the number of months employed.
Ans - select ename, months_between(sysdate, hiredate)"hired_days" from emp_56
order by "hired_days" desc;

Question -6 Create a query to display the name and salary for all employees.
Format the salary to be 15 characters long, left padded with $. Label the
column SALARY.
Ans - select lpad(salary, 15, '$') from emp_56;

Question -7 Create the EMPLOYEE2 table based on the structure on the


default EMP table. Include only the EMPNO, ENAME and DEPTNO
columns. Name the new columns in your new table as ID, LAST_NAME, and
DEPT_ID resp.
Ans - create table employee2_56 as select eno “id”, ename “last_name”, deptno
“dept_id” from emp_56;

Question -8 Rename the EMPLOYEE2 table to EMPLOYEE.


Ans - alter table employee2_56 rename to employee_56;

Question -9 Mark the LAST_NAME column from the EMPLOYEE table as


UNUSED.
Ans- not to be done by “Div A”

Question -10 Add column LAST_NAME in the EMPLOYEE table.


Ans - alter table employee_56 add last_name varchar2(30);

You might also like