SQL VIEW with examples..

Posted by Gopal_nivas under Sql Server on 12/6/2010 | Points: 10 | Views : 14215 | Status : [Member] | Replies : 17
hi..

i want to know the purpose of sql view with examples..

what is the main use..

is it the right way to perform insert,update operations in a "view"..

need ur suggestions with example..

regards
gopal.s




Responses

Posted by: Lalji_mer on: 12/6/2010 [Member] Bronze | Points: 25

Up
0
Down
SQL VIews are generally used to make querying data easier.

show here more details
http://www.experts-exchange.com/Database/MySQL/Q_23954833.html

will get here Example
http://www.w3schools.com/SQl/sql_view.asp

LP MER

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 12/6/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Gopal,

View is called as Temp Table (or) Virtual Table.Its get a data from one (or) more table. we create view for one table means if any insert (or) update the view means its also affect the original table.
Main use of view is just create a query for using different table and get the values from that table.But performance wise its very slow to execute.

Get More idea refer those links...

http://www.codeproject.com/KB/database/View.aspx

http://www.c-sharpcorner.com/UploadFile/skumaar_mca/viewsinsqlserver200510132009103348AM/viewsinsqlserver2005.aspx

Cheers :)

Thanks,
T.Saravanan

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: PandianS on: 12/6/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi

1. View is a Virtual table. Not a Temporary, Physical table.
2. View is used to Encapsulate/protect some importent/sensitive column data.

i.e:
- You might have faced some situation in your company like... You don't have direct rights to access the actual physical Table... Instead you only have access the View instaed. The meaning is , They have protected/encapsulated some importent/sensitive column.
So, you can only access the columns of a table which they have provided inside the View, But you can not access all the columns from the Table.

- Performing Insert, Update & Delete is not recommended using View. The view is recommended for Read operation, Not for write operation, In that case, you have to use Stored Procedure, But you can not see the actual procedures' script like what they have used inside the procedure , The actual procedure will also be Encrypted. This is also one of Encapsulation of hiding Business rules/sensitive column.

- You will not have rights to View the definition of the Stored Procedures /View and don't have direct access to the physical table.

- Some authorized person only have Sysadmin rights....

Please refer for deep drive into View...
http://msdn.microsoft.com/en-us/library/ms187956.aspx

Cheers

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 5/20/2012 [Member] Starter | Points: 25

Up
0
Down
1) VIEW IS AN VIRTUAL TABLE
2) VIEW ITS OCCUPY ANY MEMORY SPACE
3) CANNOT INSERT ,UPDATE,DELETE IN VIEW.
4) SECURITY PURPOSE TO USE VIEW.
5) VIEW IS A TEMPORARY TABLE.
6) VIEW HAS NO DIRECT ACCESS TO THE PHYSICAL TABLE.


REGARDS
SRIRAM.R



sriram

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 6/2/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi @Sriram....

The 3rd point you have mentioned, I think we can INSERT ,UPDATE,DELETE IN A VIEW !
Can you just clarify a bit !


Thanks and Regards
Akiii


Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/4/2012 [Member] Silver | Points: 25

Up
0
Down
@Akiii
We are performing INSERT ,UPDATE,DELETE into the underlying table using the view.
View is just like a virtual table.

http://msdn.microsoft.com/en-us/library/ms187956.aspx
http://www.codeproject.com/Articles/38560/Overview-of-View-in-SQL-Server-2005

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 6/4/2012 [Member] Bronze | Points: 25

Up
0
Down
@CGN007.....thanks !


Regards
Akiii

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/15/2012 [Member] Bronze | Points: 25

Up
0
Down
Refer this link

http://www.w3schools.com/sql/sql_view.asp ]
http://www.techonthenet.com/sql/views.php

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/15/2012 [Member] Bronze | Points: 25
Posted by: CGN007 on: 6/15/2012 [Member] Silver | Points: 25

Up
0
Down
@Akiii
Welcome man..
Now its time to mark as answer...

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 6/15/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi @CGN007.....This is not my post. This is gopal's post, only he can mark as an answer !


Regards
Akiii

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/16/2012 [Member] Silver | Points: 25

Up
0
Down
Ok fine...


Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/16/2012 [Member] Silver | Points: 25

Up
0
Down
@Gopal_nivas
Now its time to mark as answer...

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 7/31/2012 [Member] Silver | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 7/31/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
CREATE VIEW View_Name

AS
SELECT * FROM Table_name
WHERE condition


Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 7/31/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
hi.. Look at this link.
http://www.codeproject.com/Articles/266985/Views-In-SQL-Server

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 7/31/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi. @Gopal_nivas
Mark As Answer, if above post helps u.

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response