0% found this document useful (0 votes)
17 views1 page

Create Table Employee, Department, Address Employee (Eid, E - Name, Hire - Date, D - Id)

The document creates three tables - Employee, Department, and Address using SQL commands. It then inserts sample records into the tables. It performs an outer join across the tables and a select query to retrieve data.

Uploaded by

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

Create Table Employee, Department, Address Employee (Eid, E - Name, Hire - Date, D - Id)

The document creates three tables - Employee, Department, and Address using SQL commands. It then inserts sample records into the tables. It performs an outer join across the tables and a select query to retrieve data.

Uploaded by

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

Create table Employee, Department, Address Employee (Eid, E_name, Hire_date, D_id)

CREATE TABLE Employee(Eid NUMBER, E_name VARCHAR(20), Hire_Date VARCHAR(20), D_id NUMBER);

Create table Department(D_id, D_name, E_id)

CREATE TABLE Department(D_id NUMBER, D_name VARCHAR(20), E_id NUMBER);


Create table Address (Street_addres, E_id, Country)

CREATE TABLE ADDRESS(street_address VARCHAR(20), E_id NUMBER, Country VARCHAR(20));

Part (a): Insert Records

INSERT INTO Employee (Eid, E_name, Hire_date, D_id) VALUES(1,'Adam', '10-12-2020',1);

INSERT INTO Employee (Eid, E_name, Hire_date, D_id) VALUES(2,'Allak', '19-12-2020',2);

INSERT INTO Employee (Eid, E_name, Hire_date, D_id) VALUES(3,'James', '28-12-2020',3);

INSERT INTO Department (D_id, D_name,E_id) VALUES(1,'IT',1);

INSERT INTO Department (D_id, D_name,E_id) VALUES(2,'Maths',2);

INSERT INTO Department (D_id, D_name,E_id) VALUES(3,'Physics',3);

INSERT INTO ADDRESS (street_address, E_id, Country) VALUES ('Haripur',1,'Pakistan');

INSERT INTO ADDRESS (street_address, E_id, Country) VALUES ('Khanpur',2,'Pakistan');

INSERT INTO ADDRESS (street_address, E_id, Country) VALUES ('Lahore',3,'Pakistan');

Part (b): Outer Join

SELECT A.Eid,A.E_name, A.Hire_Date,B.D_name, C.street_address,C.country FROM ADDRESS


C,Department B, Employee A WHERE b.E_id(+)=a.Eid AND c.E_id(+)=a.Eid;

Part (c):

SELECT D_name from Department WHERE E_id=2;

Part (d):

UPDATE Address SET street_address='Karachi' WHERE E_id=3;

You might also like