January 23, 2011 at 3:28 pm
I'm just getting started using MSS and wanted to know what exactly is the difference between a query and a view?
January 23, 2011 at 4:05 pm
From security point of view if you use a query that references the table, the user must have permissions directly on the tables, but if you use a view and the creator of the view is also the owner of all the objects that the view references, then the users can have permissions to use the view even if they don’t have permissions on the tables. From security point of view this has a very important impact. For example with view you can limit the columns and records will be returned to the user, but if you grant permission to run select statement on the table the user can have permission to read data that you don’t want him to see.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
January 23, 2011 at 5:54 pm
blackwell (1/23/2011)
I'm just getting started using MSS and wanted to know what exactly is the difference between a query and a view?
A view is nothing but a catalogued query you can re-use once and again not worring if that particular part of your code will work or not - once tested and catalogued you can be sure it will return what is supposed to.
Views help you to expose data in a particular way, it can be from a single table or a set of table filtering both rows and columns as needed - as previous poster noted this is important to workaround security issues.
An example? the old-and-good payroll one. Employee table includes the salary of each employee but most people are not supposed to have access to that particular column - as well as SSN, Driver's License #, etc so you create a Employee_View that does not exposes confidential data.
Hope this helps.
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply