Your SlideShare is downloading. ×
MySQL Views
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

MySQL Views

588
views

Published on

MySQL Views …

MySQL Views
- Definition
- Restrictions
- Syntax
- Example
- Advantages and disadvantages

Published in: Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
588
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MySQL Views Reggie Niccolo Santos UP ITDC
  • 2. Outline  What is a view?  Restrictions when using views  Syntax  Sample CREATE VIEW statement  Advantages and disadvantages of using views
  • 3. What is a view?  Virtual table based on the result-set of an SQL statement  The fields in a view are fields from one or more real tables in the database
  • 4. Restrictions on views  The SELECT statement cannot contain a subquery  The SELECT statement cannot refer to system or user variables  Any table or view referred to in the definition must exist
  • 5. Restrictions on views  A temporary VIEW cannot be created  A VIEW cannot be associated with a trigger
  • 6. Syntax: CREATE VIEW CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] [DEFINER = { user | CURRENT_USER }] [SQL SECURITY { DEFINER | INVOKER }] VIEW view_name [(column_list)] AS select_statement [WITH [CASCADED | LOCAL] CHECK OPTION]
  • 7. Example: View CREATE OR REPLACE VIEW `view_track_details` AS SELECT TRK.id, TRK.title AS 'track_title', TRK.rating, TRK.len AS 'length', TRK.count AS 'play_count', ALB.title AS 'album_title', ART.`name` AS 'artist', GNR.`name` AS 'genre' FROM track TRK JOIN album ALB ON TRK.album_id = ALB.id JOIN artist ART ON ALB.artist_id = ART.id JOIN genre GNR ON TRK.genre_id = GNR.id;
  • 8. “Avie w is no thing m o re than a pse udo -table do ing the wo rk o f a de fine d q ue ry. ”
  • 9. Advantages and disadvantages Advantages:  Easily maintainable pseudo-tables of data  Added level of security by not exposing the table structure of the application Disadvantages:  Performance hit
  • 10. Advantages and disadvantages Advantages:  Easily maintainable pseudo-tables of data  Added level of security by not exposing the table structure of the application Disadvantages:  Performance hit
  • 11. References  http://www.w3schools.com/sql/sql_view.asp  Http://net.tutsplus.com/tutorials/databases/introdu  Http://zetcode.com/databases/mysqltutorial/views