DMA Chapter No3
DMA Chapter No3
DMA Chapter No3
•View
•Sequence
•Index
•Snapshot
•Synonyms
View
• In SQL, a view is a virtual table based on the
result-set of an SQL statement.
• A view contains rows and columns, just like a
real table. The fields in a view are fields from
one or more real tables in the database.
• View is logical part of table which can contain
all rows of a table or select some rows from a
table.
Syntax
• CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Operation on View
• Create View
• Update View
• Drop View
Create View
Example
Example
Create unique index UI on employee(emp_id);
Simple Index
• Example –
• CREATE SNAPSHOT emp_snap as select * from emp;
• Complex snapshot :
In complex snapshot, a row may be based on
more than one row in a remote table via
GROUP BY operation or result of Multi-Table
Join. This consists of joined tables, views, or
grouped and complex SELECT statement
queries.
• Example –
• CREATE SNAPSHOT sampleSnps1 AS SELECT
student.rollno, student.name FROM student
UNION ALL SELECT new_student.rollno,
new_student.name FROM new_student;
• Advantages :
• Response time is improved when local read-only copy of table
exists.
• Once snapshot is built on remote database, if node containing
data from which the snapshot is built is not available. Snapshot
can be used without need to access the unavailable database.
• Ease network loads.
• Data subsetting.
• Disconnected computing.
• Mass deployment.
• Disadvantages :
• Snapshots are not reachable when primary database goes offline.
• It does not support full text indexing.
• Snapshot runs out of disk if data changes frequently faster.
• As no.of snapshots increases, disk space becomes problematic.
• Applications :
• Protects data.
• Maintains history of data.
• Used in testing application software.
• Used in data mining.
• Recovers data when information is lost because of human error or corruption of
data.