0% found this document useful (0 votes)
3 views2 pages

DBMS Assignment 4

The document outlines several SQL problems related to employee and department data management, including selecting constraints, altering tables, and creating views. It also includes operations such as deleting records, counting employees by hire year, and creating a summary view for department salaries. Additionally, it shows how to drop constraints and views as part of database maintenance tasks.

Uploaded by

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

DBMS Assignment 4

The document outlines several SQL problems related to employee and department data management, including selecting constraints, altering tables, and creating views. It also includes operations such as deleting records, counting employees by hire year, and creating a summary view for department salaries. Additionally, it shows how to drop constraints and views as part of database maintenance tasks.

Uploaded by

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

Problem:1

SELECT OWNER, CONSTRAINT_NAME, CONSTRAINT_TYPE


FROM ALL_CONSTRAINTS
WHERE TABLE_NAME = 'EMP_IT';

ALTER TABLE EMP_IT


DROP CONSTRAINT "SYS_C00135694944";

ALTER TABLE EMP_IT


ADD CONSTRAINT F_KEY FOREIGN KEY (DEPTNO)
REFERENCES DEPT_IT (DNO) ON DELETE CASCADE;

DELETE FROM DEPT_IT


WHERE UPPER(DNAME) = 'RESEARCH';

...........................................................................

Problem:2

SELECT * FROM EMP_IT E


WHERE (DEPTNO, HIREDATE) IN
(SELECT E.DEPTNO, MAX(HIREDATE)
FROM EMP_IT E
GROUP BY E.DEPTNO)
ORDER BY E.DEPTNO;

............................................................................

Problem:3

SELECT EXTRACT(YEAR FROM HIREDATE) AS JOIN_YEAR, COUNT(*) AS NUM_EMPLOYEES


FROM EMP_IT
GROUP BY EXTRACT(YEAR FROM HIREDATE)
ORDER BY NUM_EMPLOYEES DESC
FETCH FIRST ROW ONLY;

.........................................................................

Problem:4

CREATE TABLE DEPT_IT_IT AS


SELECT E.Eno, E.Ename, E.Job, E.Sal
FROM EMP_IT E
WHERE E.Deptno = 30;

...........................................................................

Problem:5
SELECT OWNER, CONSTRAINT_NAME, CONSTRAINT_TYPE
FROM ALL_CONSTRAINTS
WHERE TABLE_NAME = 'EMP_IT';

ALTER TABLE EMP_IT


DROP CONSTRAINT SQL_GFTXEJJHCUNGDZABDVIEDNXIF;

...............................................................................
Problem:6

CREATE OR REPLACE VIEW DEPT_SUMMARY_IT AS


SELECT D.DNAME AS DEPT_NAME,
MIN(E.SAL) AS MIN_SAL,
MAX(E.SAL) AS MAX_SAL,
AVG(E.SAL) AS AVG_SAL
FROM DEPT_IT D
JOIN EMP_IT E ON D.DNO = E.DEPTNO
GROUP BY D.DNO, D.DNAME
ORDER BY D.DNAME;

...................................................................................
...

Problem:7

DROP VIEW DEPT_SUMMARY_IT;

..................................................................................

You might also like