SlideShare uma empresa Scribd logo
1 de 11
MySQL Views
Reggie Niccolo Santos
UP ITDC
Outline

What is a view?

Restrictions when using views

Syntax

Sample CREATE VIEW statement

Advantages and disadvantages of using
views
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
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
Restrictions on views

A temporary VIEW cannot be created

A VIEW cannot be associated with a trigger
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]
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;
“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. ”
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
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
References

http://www.w3schools.com/sql/sql_view.asp

Http://net.tutsplus.com/tutorials/databases/introdu

Http://zetcode.com/databases/mysqltutorial/views

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
8. transactions
8. transactions8. transactions
8. transactions
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
 
pl/sql Procedure
pl/sql Procedurepl/sql Procedure
pl/sql Procedure
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
PL/SQL - CURSORS
PL/SQL - CURSORSPL/SQL - CURSORS
PL/SQL - CURSORS
 
Joins And Its Types
Joins And Its TypesJoins And Its Types
Joins And Its Types
 
Create table
Create tableCreate table
Create table
 
Oracle Database Trigger
Oracle Database TriggerOracle Database Trigger
Oracle Database Trigger
 
Data Manipulation Language
Data Manipulation LanguageData Manipulation Language
Data Manipulation Language
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
Sql join
Sql  joinSql  join
Sql join
 
Packages - PL/SQL
Packages - PL/SQLPackages - PL/SQL
Packages - PL/SQL
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
Degree of relationship set
Degree of relationship setDegree of relationship set
Degree of relationship set
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
 
1.2 sql create and drop table
1.2 sql create and drop table1.2 sql create and drop table
1.2 sql create and drop table
 

Destaque

View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
Framgia Vietnam
 

Destaque (11)

View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
My MySQL SQL Presentation
My MySQL SQL PresentationMy MySQL SQL Presentation
My MySQL SQL Presentation
 
Vistas MySql
Vistas MySqlVistas MySql
Vistas MySql
 
Mysql Indexing
Mysql IndexingMysql Indexing
Mysql Indexing
 
Vistas en mySql
Vistas en mySqlVistas en mySql
Vistas en mySql
 
MySQL: Indexing for Better Performance
MySQL: Indexing for Better PerformanceMySQL: Indexing for Better Performance
MySQL: Indexing for Better Performance
 
Procedimientos almacenados en MySQL
Procedimientos almacenados en MySQLProcedimientos almacenados en MySQL
Procedimientos almacenados en MySQL
 
Knowledgebase vs Database
Knowledgebase vs DatabaseKnowledgebase vs Database
Knowledgebase vs Database
 
Group decision support systems (gdss)
Group decision support systems (gdss)Group decision support systems (gdss)
Group decision support systems (gdss)
 
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
 

Semelhante a MySQL Views

Sql server ___________session_16(views)
Sql server  ___________session_16(views)Sql server  ___________session_16(views)
Sql server ___________session_16(views)
Ehtisham Ali
 

Semelhante a MySQL Views (20)

View
ViewView
View
 
View
ViewView
View
 
Lec 09 SQL - 3.pptx
Lec 09 SQL - 3.pptxLec 09 SQL - 3.pptx
Lec 09 SQL - 3.pptx
 
Les11
Les11Les11
Les11
 
View
ViewView
View
 
Designing and Creating Views, Inline Functions, and Synonyms
 Designing and Creating Views, Inline Functions, and Synonyms Designing and Creating Views, Inline Functions, and Synonyms
Designing and Creating Views, Inline Functions, and Synonyms
 
Les10
Les10Les10
Les10
 
Sql views
Sql viewsSql views
Sql views
 
View
ViewView
View
 
Sql viwes
Sql viwesSql viwes
Sql viwes
 
Oracle Database View
Oracle Database ViewOracle Database View
Oracle Database View
 
Implementing views
Implementing views Implementing views
Implementing views
 
MS SQL SERVER: Creating Views
MS SQL SERVER: Creating ViewsMS SQL SERVER: Creating Views
MS SQL SERVER: Creating Views
 
MS SQLSERVER:Creating Views
MS SQLSERVER:Creating ViewsMS SQLSERVER:Creating Views
MS SQLSERVER:Creating Views
 
MS Sql Server: Creating Views
MS Sql Server: Creating ViewsMS Sql Server: Creating Views
MS Sql Server: Creating Views
 
Creating other schema objects
Creating other schema objectsCreating other schema objects
Creating other schema objects
 
Oracle view
Oracle viewOracle view
Oracle view
 
Sql server ___________session_16(views)
Sql server  ___________session_16(views)Sql server  ___________session_16(views)
Sql server ___________session_16(views)
 
6232 b 04
6232 b 046232 b 04
6232 b 04
 
Chapter 07 ddl_sql
Chapter 07 ddl_sqlChapter 07 ddl_sql
Chapter 07 ddl_sql
 

Mais de Reggie Niccolo Santos

Mais de Reggie Niccolo Santos (15)

Securing PHP Applications
Securing PHP ApplicationsSecuring PHP Applications
Securing PHP Applications
 
Introduction to Web 2.0
Introduction to Web 2.0Introduction to Web 2.0
Introduction to Web 2.0
 
UI / UX Engineering for Web Applications
UI / UX Engineering for Web ApplicationsUI / UX Engineering for Web Applications
UI / UX Engineering for Web Applications
 
Computability - Tractable, Intractable and Non-computable Function
Computability - Tractable, Intractable and Non-computable FunctionComputability - Tractable, Intractable and Non-computable Function
Computability - Tractable, Intractable and Non-computable Function
 
Algorithms - Aaron Bloomfield
Algorithms - Aaron BloomfieldAlgorithms - Aaron Bloomfield
Algorithms - Aaron Bloomfield
 
Program Logic Formulation - Ohio State University
Program Logic Formulation - Ohio State UniversityProgram Logic Formulation - Ohio State University
Program Logic Formulation - Ohio State University
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Computational Thinking and Data Representations
Computational Thinking and Data RepresentationsComputational Thinking and Data Representations
Computational Thinking and Data Representations
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game Development
 
Application Testing
Application TestingApplication Testing
Application Testing
 
Application Security
Application SecurityApplication Security
Application Security
 
PHP MVC
PHP MVCPHP MVC
PHP MVC
 
MySQL Transactions
MySQL TransactionsMySQL Transactions
MySQL Transactions
 
MySQL Cursors
MySQL CursorsMySQL Cursors
MySQL Cursors
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 

MySQL Views