0% found this document useful (0 votes)
15 views6 pages

22bce20428 DBMS Lab1

The document describes creating tables for employees and departments in a database, inserting sample data, and writing queries to retrieve data from the tables. It includes creating the tables, inserting sample data, and 8 queries to retrieve various data fields and filter on conditions.

Uploaded by

potmail3000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

22bce20428 DBMS Lab1

The document describes creating tables for employees and departments in a database, inserting sample data, and writing queries to retrieve data from the tables. It includes creating the tables, inserting sample data, and 8 queries to retrieve various data fields and filter on conditions.

Uploaded by

potmail3000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

VIT-AP UNIVERSITY, ANDHRA PRADESH

Name:- D.S.S.SASHANK
Reg No:- 22BCE20428
Slot:- L41 – L42

LAB-1
1) Create Table Employee with attributes firstName, LastName, SSN,Address,
Salary, Birthday, Sex, SupervisorSSN, DepartmentNo.

SQL code:-

CREATE TABLE Employee (


firstName VARCHAR(50),
lastName VARCHAR(50),
SSN VARCHAR(11), -- Assuming SSN is stored as a string
Address VARCHAR(100),
Salary DECIMAL(10,2), -- Assuming salary is stored as a decimal number
Birthday DATE,
Sex CHAR(1), -- Assuming 'M' for Male, 'F' for Female
SupervisorSSN VARCHAR(11), -- Assuming SSN of supervisor is stored as a
string
DepartmentNo INT
);

OUTPUT:

2) Create a Table Department with attributes DNo, DNAMe, ManagerSSN,


MgrStartdate.

SQL code:-

CREATE TABLE Department (


DNo INT PRIMARY KEY,
DName VARCHAR(100),
ManagerSSN VARCHAR(11), -- Assuming SSN of manager is stored as a string
MgrStartDate DATE
);

OUTPUT:
3) Insert the data given above in both employee, department and project
tables.

SQL code:

INSERT INTO Employee (firstName, lastName, SSN, Address, Salary, Birthday,


Sex, SupervisorSSN, DepartmentNo)
VALUES
('sri satya', 'D', '123-45-6789', '47-16/6, benz circle', 50000.00, '2000-01-01',
'M', '987-65-4321', 1),
('Jayram', 'S', '987-65-4321', '31-29/5, park road', 60000.00, '2001-02-02', 'M',
NULL, 2),
('Mithin', 'p', '234-56-7890', '12-23/2, ramarao statue road', 55000.00, '2002-
03-03', 'M', '123-45-6789', 1);

-- Inserting data into the Department table


INSERT INTO Department (DNo, DName, ManagerSSN, MgrStartDate)
VALUES
(1, 'Engineering', '123-45-6789', '2023-01-01'),
(2, 'Marketing', '987-65-4321', '2023-02-01');

OUTPUT:
4) Display all the employees’ information.

SQL code:

SELECT * FROM Employee;

OUTPUT:

5) Display Employee name along with his SSN and Supervisor SSN.

SQL code:

SELECT firstName, lastName, SSN, SupervisorSSN


FROM Employee;

OUTPUT:
6) Display the employee names whose bdate is '02-02-2001'.
SQL code:

SELECT firstName, lastName


FROM Employee
WHERE Birthday = '02-02-2001'

OUTPUT:

7) Display salary of the employees without duplications.

SQL code:

SELECT DISTINCT Salary


FROM Employee;

OUTPUT:
8) Display the MgrSSN, MgrStartDate of the manager of 'Engineering'
department.

SQL code:

SELECT Department.ManagerSSN, Department.MgrStartDate


FROM Department
JOIN Employee ON Department.ManagerSSN = Employee.SSN
WHERE Department.DName = 'Engineering';

OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy