Unix Technical Forum

views not updateable

This is a discussion on views not updateable within the SQL Server forums, part of the Microsoft SQL Server category; --> How do I make a view non updateable? I want to create a view so that I will not ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 02:44 PM
othellomy@yahoo.com
 
Posts: n/a
Default views not updateable

How do I make a view non updateable? I want to create a view so that I
will not be able to update, insert or delete the view so that base
table is not affected (except dropping the view itself). Thanks.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 02:44 PM
othellomy@yahoo.com
 
Posts: n/a
Default Re: views not updateable

On Mar 23, 4:06 pm, othell...@yahoo.com wrote:
> How do I make a view non updateable? I want to create a view so that I
> will not be able to update, insert or delete the view so that base
> table is not affected (except dropping the view itself). Thanks.


I have tried:
revoke delete,insert,update on v_t1 to dbo

bit its not working...

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 02:44 PM
othellomy@yahoo.com
 
Posts: n/a
Default Re: views not updateable

On Mar 23, 4:13 pm, othell...@yahoo.com wrote:
> On Mar 23, 4:06 pm, othell...@yahoo.com wrote:
>
> > How do I make a view non updateable? I want to create a view so that I
> > will not be able to update, insert or delete the view so that base
> > table is not affected (except dropping the view itself). Thanks.

>
> I have tried:
> revoke delete,insert,update on v_t1 to dbo
>
> bit its not working...


Okay found a solution. If I introduce an aggregate function then it
works. So I ended up aggregating all the columns from the select list.
So instead of saying:
Create view view1 as
Select column1, column2
>From Base_table


Not Updateable:
Create view view1 as
Select column1, column2
>From Base_table

Group by column1,column2

I wish there is an easier way than this.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-01-2008, 02:44 PM
Damien
 
Posts: n/a
Default Re: views not updateable

On Mar 23, 10:34 am, othell...@yahoo.com wrote:
> On Mar 23, 4:13 pm, othell...@yahoo.com wrote:
>
> > On Mar 23, 4:06 pm, othell...@yahoo.com wrote:

>
> > > How do I make a view non updateable? I want to create a view so that I
> > > will not be able to update, insert or delete the view so that base
> > > table is not affected (except dropping the view itself). Thanks.

>
> > I have tried:
> > revoke delete,insert,update on v_t1 to dbo

>
> > bit its not working...

>
> Okay found a solution. If I introduce an aggregate function then it
> works. So I ended up aggregating all the columns from the select list.
> So instead of saying:
> Create view view1 as
> Select column1, column2
>
> >From Base_table

>
> Not Updateable:
> Create view view1 as
> Select column1, column2>From Base_table
>
> Group by column1,column2
>
> I wish there is an easier way than this.


create trigger T_NoUpdates on view1 INSTEAD OF INSERT,UPDATE,DELETE AS
RAISERROR('No updates allowed',16,1)

Damien

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-01-2008, 02:45 PM
Hugo Kornelis
 
Posts: n/a
Default Re: views not updateable

On 23 Mar 2007 03:13:01 -0700, othellomy@yahoo.com wrote:

>On Mar 23, 4:06 pm, othell...@yahoo.com wrote:
>> How do I make a view non updateable? I want to create a view so that I
>> will not be able to update, insert or delete the view so that base
>> table is not affected (except dropping the view itself). Thanks.

>
>I have tried:
>revoke delete,insert,update on v_t1 to dbo
>
>bit its not working...


Hi othellomy,

The REVOKE keyword is to revoke a permission that was earlier GRANTed
explicitly.

To explicitly deny access to an object that would by default allow
access, you use DENY:

DENY DELETE, INSERT, UPDATE ON v_t1 TO ALL

However, this will not affect any user in the db_owner database role or
any user in the sysadmin server role, since security checks are bypassed
for these users.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:42 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com