+ 2

What is the difference between select query and view?

2nd Aug 2016, 3:34 AM
Yury Vinogradov
7 Answers
+ 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.
4th Aug 2016, 4:06 PM
Jacob Lynn
Jacob Lynn - avatar
+ 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
2nd Aug 2016, 9:04 AM
Akshay Thakre
Akshay Thakre - avatar
+ 1
And end user can call view by it name without creating a query: SELECT * FROM ViewName
2nd Aug 2016, 9:11 AM
Yury Vinogradov
+ 1
I can add just to say that a view is an object of a database based on "select " as an instruction... :-)
4th Aug 2016, 11:43 PM
Jacobs Masengo
Jacobs Masengo - avatar
0
do you mean view or show !?
6th Aug 2016, 11:28 AM
Mohamed Fawzy
Mohamed Fawzy - avatar
0
compare between Query and View?
11th Apr 2023, 10:03 AM
Zaid Anagreh
Zaid Anagreh - avatar
- 1
end user does not knw whether it's a view or a table he can do crud operation on it
2nd Aug 2016, 9:15 AM
Akshay Thakre
Akshay Thakre - avatar