How the Mysql View is working Internally ?
create view testView as select * from employee;
if run this what will happen internally?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Usually, crating a view doesn’t really do much until it is called on. It pretty much just gets validated until it is used.
Views usually use the
MERGEmethod which merges the query for the view with the query that calls it. The other method for views isTEMP TABLEwhich creates a temporary table whenever it is needed, but this is less common.An basic example of a view using the
MERGEmethod:View Query:
Calling Query:
MySQL basically executes this query as:
However, since the queries get merged and optimized, it would be optimized to a simpler form like this: