MS SQLSERVER:Creating Views

698 views

Published on

MS SQLSERVER:Creating Views

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
698
On SlideShare
0
From Embeds
0
Number of Embeds
80
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

MS SQLSERVER:Creating Views

  1. 1. 13<br />SQL SERVER: CREATING VIEWS<br />
  2. 2. What is a View<br />A View is a query which is stored in a server in the form of an object. The Power of a view lies in the fact that it can be referenced as a table. It provides an abstraction of the underlying data.<br />The Main use of using a view is the security that it offers. A Third-Person may be restricted to view only a portion of a database, while hiding the rest of sensitive data<br />The Illustration is made in the next slide.<br />
  3. 3. What is a View<br />Remember that the view exists as query and not as a table<br />
  4. 4. SQL Views<br />Points to remember about SQL Views:<br /><ul><li> View is inherently a query.
  5. 5. Changes made in the view will not alter a table. An explicit update must be </li></ul> made to effect a change.<br /><ul><li> All changes can be made in the view except DDL commands
  6. 6. Views are used to provide additional security over data
  7. 7. It also prevents unwanted tampering of sensitive data
  8. 8. Views provide performance benefits</li></li></ul><li>Creating Views<br />The SQL syntax for creating a view is as follows:<br />Create view &lt;viewName&gt;<br />As<br /> …QUERY that results in a table/data…<br />GO<br />Example:<br />Consider a student table:<br />Create view NameList<br />As<br />Select regno,name from student<br />go<br />View <br />
  9. 9. Using Views<br />After creating a view, it can used as if it is a table. It can queried like a normal table:<br />Select * from nameList<br />The above query on the view will return:<br />Thus, a view provides a good level of abstraction over the database.<br />
  10. 10. Modifying Views<br />An existing view is modified like using the alter view statement.<br />The Syntax<br />Alter view &lt;viewName&gt;<br />As<br /> …QUERY that results in a table/data…<br />GO<br />Similar to the alter procedure statement, the alter table command redefines the existing view defenition.<br />
  11. 11. Deleting Views<br />The Syntax:<br />Drop view &lt;viewName&gt;<br />Example:<br />Drop view nameList<br />
  12. 12. Summary<br />13. Creating Views<br /><ul><li> About Views
  13. 13. Creating Views
  14. 14. Modifying Views
  15. 15. Deleting Views</li></li></ul><li>Visit more self help tutorials<br />Pick a tutorial of your choice and browse through it at your own pace.<br />The tutorials section is free, self-guiding and will not involve any additional support.<br />Visit us at www.dataminingtools.net<br />

×