sql server - How is "create view" evaluated in SQL? -
i have - maybe simple - question how create view
, select ... viewname
evaluated. know how create views , use them, have explain procedure of 2 commands graphically , text school.
well, following (i using microsoft sql server 2012 @ moment, should not matter, it? know mysql too, if there differences):
-- create schema test create schema temp go -- create view create view temp.vlt select lnr,tnr,menge ltp.ltp go -- select data view select * temp.vlt
a view
alias select query, evaluated in subquery, right? if so, right, that
select * temp.vlt
is same as
select * (select lnr,tnr,menge ltp.ltp) vlt
?
i mean, know gives same result, evaluated same way, or wrong?
thank responsing! eisenbahnfan
your understanding correct @ high level. first, views can differ among databases. mysql, in particular, has bunch of limitations such no subqueries in from
clause. but, in fact, mysql pretty operates way describe.
you have right understanding in general. code of view merged query being referenced. here specific language in documentation:
when sql statement references nonindexed view, parser , query optimizer analyze source of both sql statement , view , resolve them single execution plan. there not 1 plan sql statement , separate plan view.
there type of view called "indexed views" materialize data. in case, code view not run, results used in query.
Comments
Post a Comment