Professional Documents
Culture Documents
DMS (22319) - Chapter 3 Notes
DMS (22319) - Chapter 3 Notes
MONTHS_BETWEEN(date1, date2)
Department table:
◦ Dept_id (Number) / identifier
◦ Dept_Name (varchar)
Department table:
◦ Dept_id (Number) / identifier
◦ Dept_Name (varchar)
Department table:
◦ Dept_id (Number) / identifier
◦ Dept_Name (varchar)
Department table:
◦ Dept_id (Number) / identifier
◦ Dept_Name (varchar)
Example:
SELECT * FROM Employee WHERE Emp_id IN (SELECT Emp_id
FROM Employee WHERE SALARY > 6500) ;
Example:
UPDATE EMP_VIEW
SET AGE = 35
WHERE name = 'Ramesh';
SELECT * FROM EMP_VIEW;
Syntax:
INSERT INTO view_name(column1, column2 , column3,..) VALUES
(value1, value2, value3..);
Example:
INSERT INTO EMP_VIEW (Name, Age) VALUES (‘Sanchi’, 18);
Example:
In this example we will create a View named MarksView from
two tables StudentDetails and StudentMarks.
CREATE VIEW MarksView AS SELECT StudentDetails.NAME,
StudentDetails.ADDRESS, StudentMarks.MARKS FROM
StudentDetails, StudentMarks WHERE StudentDetails.NAME =
StudentMarks.NAME;
Database Management System (DMS) Mr. S. Y. Divekar
View with subquery :
To create a View a subquery is used to return data that will be
used in the main query as a condition to further restrict the data
to be retrieved
Example:
CREATE VIEW Emp_View2 AS SELECT * FROM Employee WHERE
Emp_id IN (SELECT Emp_id FROM Employee WHERE SALARY >
1500) ;
Syntax:
DROP VIEW view_name;
Example:
DROP VIEW EMP_VIEW;
Example:
The following statement drops the sequence sequence_1 .
Syntax:
CREATE INDEX index_name ON table_name (column_name1,
column_name2,.. );
Example:
The following statement drops the Index Index_1 .
Example:
DROP PUBLIC SYNONYM Employee;
DROP SYNONYM Emp;