Sie sind auf Seite 1von 2

SH1680

SQL Views
I. What are SQL Views?
 These are SELECT statements saved in the database.
 Once saved, these can be referred to the same as any table in the database.
 These do not contain data, but allow manipulation similar to tables as if the view was
a real table with data.

A. Benefits of using Views


1. Views can reduce complexity by allowing complex SELECT statements to be
simplified due to some parts being able to be taken by the views themselves.
2. Views can increase reusability. This is applicable on situations where tables are
joined frequently by using views to avoid joining them repeatedly every time you
need data.
3. Views can properly format data. They can be used on a column that is not
formatted correctly in your database by using functions to format the specified
column on an exact order or specification.
4. Views can create calculated columns. This is through results obtained from
operations done on reference tables. Users can reference these views as they are
readily available.
5. Views can be used to rename column names. If you have a database containing
column names that are complex, you may create views with column aliases to
make those column names simpler.
6. Views can create subsets of data. Views can contain only the relevant parts of
the tables they reference to produce a more useful and meaningful table of data.
7. Views can be used to enforce security restrictions. This is by granting access
to a view table for users instead of the original tables where operations are
restricted to only those who are authorized to alter their content.

II. CREATE VIEW


 It creates a new view from existing database tables.
 View is stored within the database.
 After a view has been created, it can be brought back by executing a SELECT
statement together with its view name.

III. ALTER VIEW


 It allows the editing or alteration of a created or existing view.
 When altering a view, the complete SELECT statement contained in the view MUST
be specified. The original SELECT statement in the view gets replaced by the new
SELECT statement that you specify.
 Creating or altering a view does not return any data. It only creates or modifies the
definition of the view.

06 Handout 1 *Property of STI


Page 1 of 2
SH1680

IV. DROP VIEW


 It deletes a created or existing view.
 The deleted view is basically deleted from the database; exercise caution when
deleting unnecessary views.

References
 Coronel, C., Crockett, K., and Rob, P. (2012). Database systems: Design,
implementation & management. USA: Cengage Learning EMEA
 Singh, S. K. (2009). Database systems: Concepts, design and applications. India:
Pearson Education.
 Adamski, J. and Pratt, P. (2012). Database management systems (7th ed.). USA:
Cengage Learning
 Elmarsi, R. and Navathe, S. (2010). Fundamentals of database systems (6th ed.).
Pearson Education South Asia Pte. Ltd.
 Rockoff, L. (2011). The language of SQL. Cengage Learning.
 Korth, H., Silberschatz, A., and Sudarshan, S. (2011). Database system concepts (6th
ed.). New York. McGraw-Hill.

06 Handout 1 *Property of STI


Page 2 of 2

Das könnte Ihnen auch gefallen