Dbmslab 2
Dbmslab 2
Dbmslab 2
Lab Assignment-2
~Soumajit Pal
21BCE7214
1)Create Table Employee with attributes FirstName, LastName,
SSN, Address , Salary, Birthday, Sex, SupervisorSSN,
DepartmentNo.
Query-
CREATE TABLE Employee (
FirstName varchar,
LastName varchar,
SSN bigint,
Address varchar,
Salary bigint,
Birthday date,
Sex varchar,
SupervisorSSN bigint,
DepartmentNo int
);
2) Create a Table Department with attributes DNo, DNAME,
ManagerSSN, MgrStartdate.
Query-
create table Department(
DNo int,
DNAME varchar,
ManagerSSN bigint,
MgrStartDate varchar
);
Output-
Output-
select*from Employee
Output-
10) Alter Table department add column DepartmentPhoneNum
of NUMBER data type and insert values into this column only.
Query-
alter table Department
add DepartmentPhoneNum int;
select*from Department
Output-
11) Alter table department to modify the size of
DepartmentPhoneNum.
Query-
alter table Department
alter column DepartmentPhoneNum bigintint;
Output-
Output-
Output-
18) Add Foreign Keys using Alter Table.
Query-
alter table Employee
add foreign key(SupervisorSSN)
references DEPT(ManagerSSN)
21) Find the employee names whose salary lies in the range
between 30000 and 70000.
Query-
select FirstName,LastName
from Employee
where Salary>30000 and Salary<70000;
Output-
22) Find the employees who have no supervisor.
Query-
select FirstName,LastName
from Employee
where SupervisorSSN is null;
Output-
Output-
Output-
30) Display the first four characters and last four of the
department names using substringfunction.
Query-
select substring(DNAME,1,4),substring(DNAME,-4)
from DEPT;
Output-