You are on page 1of 12

30 23

March 2021202
March

DBMS
DBMS LabLab
ASSIGNMENT 4(2-6) AND ASSIGNMENT 5(1-5)
ASSIGNMENT 4(2-6) AND ASSIGNMENT 5(1-5)
LOVISH BANSAL.
LOVISH BANSAL.
Roll No. 101917087

E-mail Id lbansal_be19@thapar.edu
Assignment 4(2-6)
2. Display current time in hour : min : sec format

3. Display salary + commission of emp table

4. Store any date value in hiredate column of table ?

5. Display name of employee(s) who join the company in 1985 ?

6. Display name of the employee(s) who join the company this

year ?

Solution:
Script:

select to_char(sysdate+(5.5/24), 'HH12:MI:SS') "NOW" from dual ;

select to_char(sysdate+(5.5/24), 'HH12:MI:SS') "NOW" from dual ;

select to_char(sysdate+(5.5/24), 'HH12:MI:SS') "NOW" from dual ;

create table employe(Eno Int, Ename varchar(40) , hiredate Date , salary Number(20) , Commission Number(10));

Insert into employe values(1 , 'Lovish' , DATE '1985-12-17',40000,2000);

Insert into employe values(2 , 'Bhavesh' , DATE '2018-12-20',10000,1000);

Insert into employe values(3 , 'Prateek' , DATE '2019-06-25',30000,2000) ;

Insert into employe values(4 , 'Akshat' , DATE '2020-06-26',20000,1000);

Insert into employe values(5 , 'Arsh' , DATE '2021-03-15',10000,2000);

select salary + commission from employe;

select Ename from employe where to_char(hiredate, 'yyyy') = '1985';

select Ename from employe where to_char(hiredate, 'yyyy') = to_char(sysdate, 'YYYY');


Assignment 5(1-5)

1. Create table emp which has the following attributes (employee,table)


(@empno, ename, job, sal, deptno)
Where empno is primary key, ename is unique, job in (Prof, AP, and Lect), sal is not NULL, and deptno is foreign key

2. Create table dept which has the following attributes (department table)
(@deptno, dname)
Where deptno is primary key, dname in (Acc, comp, elect)

3.Create table S which has the following attributes (Salesperson table)

(@sno, sname, city)


Where sno is primary key

4. Create table P which has the following attributes (Part table)


(@pno, pname, color)
Where pno is primary key

5. Create table J which has the following attributes (ProJect table)


(@jno, jname, city)
Where jno is primary key
Solution:

Script:

create table dept(deptno int primary key, dname varchar(20) check(dname in('Acc','comp', 'elect')));
desc dept;
create table employee(empno int primary key,ename varchar(20) unique,job varchar(20) check(job in('Prof','AP', 'Lect')),sal int not null,
depno int references dept(deptno));
desc employee;
create table S(sno int primary key,sname varchar(20),city varchar(20));
desc S;
create table P(pno int primary key,pname varchar(20),color varchar(20));
desc P;
create table J(jno int primary key,jname varchar(20),city varchar(20));
desc J;
-

You might also like