+ 2
What is the difference between select query and view?
7 Réponses
+ 4
The question and the answers are not fully formed.
To the end user or analyst there is no difference between querying a view or querying a table. in fact on the same database there can not be a view and table with the same name.
Views are not meant to only hide data. in fact they are usually used to combine multiple tables or even aggregate data for an analyst to query from.
Example:
table1: database.externalaccounts as DBe
table2: database.internalaccounts as DBi
create view database.accounts as
select
DBe.col1
,DBi.col1
,DBe.state
,sum(DBe.total) as externaltotal
,sum(DBi.total) as internaltotal
from DBe
innerjoin DBi on DBe.state = DBi.state
groupby DBe.state, DBe.col1,DBi.col1
Two tables that a view combines where they have the same state, groups state and creates a new column that is a sum of the totals.
*important* views do not take up memory like tables do when not being queried. The joining and Calculations occur during execution.
+ 2
SQL query is for querying the table as per the need and view is different form query we create view of the table to hide our data view is the table that we create for the end users
+ 1
And end user can call view by it name without creating a query: SELECT * FROM ViewName
+ 1
I can add just to say that a view is an object of a database based on "select " as an instruction... :-)
0
do you mean view or show !?
0
compare between Query and View?
- 1
end user does not knw whether it's a view or a table
he can do crud operation on it