Lab Manual for DBA
Lab Manual for DBA
Lab Manual 07
Session: Fall-2024
Instructor: SHEZA SHABIR
To understand the concept of database views, their types, how to create, modify, and drop views,
and how they can be used to simplify data access and improve security. Additionally, learn to work
with Materialized Views, System Views, and Dynamic Management Views for advanced database
management.
What is a View?
1. To make queries simpler: You can save complex queries and use them like a table.
2. To secure data: You can hide parts of a table (like private columns).
3. To organize data: Show only the data you need, in the way you need.
Syntax:
Types of Views:
1. Regular View
Simplifies complex queries and provides a secure way to access specific data from tables.
When to Use:
Purpose: Combines data from multiple tables into one logical table, often used with
distributed databases.
When to Use:
Syntax:
Example:
If we had separate tables for UndergraduateStudents and GraduateStudents:
3. Materialized View
Purpose: Stores query results physically for faster access but requires refreshing to keep
data updated.
When to Use:
Syntax:
4. System View
Purpose: Built-in views provided by the database to get system metadata (e.g., schema
details, users).
Syntax:
No custom creation; you query system views directly.
Example:
View all tables in the current database:
Purpose: Used to monitor and manage the database's health, performance, and status.
Syntax:
No custom creation; you query DMVs directly.
Example:
View current running queries:
Modifying a View
Syntax:
Syntax: