PL SQL
PL SQL
PL SQL
Ques: Create an EMP Table with the column name EID, EName, Salary, City with
data type number, varchar, number and varchar respectively, display the structure
of the table, insert the records in the table and display all the records.
COMMAND:
OUTPUT:
PRACTICAL-2
COMMAND:
SELECT * FROM EMP WHERE SALARY > 40000 AND SALARY
< 80000;
OUTPUT:
COMMAND:
SELECT EID FROM EMP WHERE ENAME LIKE'A%';
OUTPUT:
iii) Name of employee whose EID is 10,9,3,14,19
COMMAND:
SELECT ENAME FROM EMP WHERE EID IN (10,9,3,14,19);
OUTPUT:
iv) Name of employee whose EID is greater than 10 and city is Delhi.
COMMAND:
SELECT ENAME FROM EMP WHERE EID >10 AND CITY='DELHI';
OUTPUT:
v) Average and maximum salary of all employee and count the no of
employee.
COMMAND:
SELECT COUNT(*),AVG(SALARY),MAX(SALARY) FROM EMP;
OUTPUT:
PRACTICAL-3
Ques.Change the data type of EID of EMP table from Number to varchar
and add one more column EDepartment with data type varchar.
COMMANDS:
OUTPUT:
COMMANDS:
OUTPUT:
PRACTICAL-4
Create a table Department with column Dep_ID, Dep_Name and set the
referential integrity with EMP table. Dep_ID should be foreign key in EMP
table and insert some record in both the table and display department name
of those employee who belongs to City Delhi.
COMMAND:
CREATE TABLE EMP(EID INT, ENAME VARCHAR(40), SALARY INT, CITY
VARCHAR(40),DEP_ID INT);
INSERT INTO EMP VALUES (101,'AMAN',78000,'DELHI',201);
INSERT INTO EMP VALUES (102,'MOHIT',90000,'DELHI',202);
INSERT INTO EMP VALUES (103,'ROHAN',78000,'SONIPAT',203);
INSERT INTO EMP VALUES (104,'SNEHA',86500,'DELHI',204);
INSERT INTO EMP VALUES (105,'KPSC',878000,'SONIPAT',205);
CREATE TABLE DEPARTMENT ( DEP_ID INT NOT NULL , DEP_NAME
VARCHAR(5 0) NOT NULL , FOREIGN KEY (DEP_ID) REFERENCES
EMP(DEP_ID));
INSERT INTO DEPARTMENT VALUES (201,'MECHANICAL');
INSERT INTO DEPARTMENT VALUES (202,'CSE');
INSERT INTO DEPARTMENT VALUES (203,'CSE');
INSERT INTO DEPARTMENT VALUES (204,'CIVIL');
INSERT INTO DEPARTMENT VALUES (205,'CIVIL');
SELECT DEP_NAME FROM EMP WHERE CITY =’DELHI’;
OUTPUT: