dbTalk Databases Forums  

views not updateable

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss views not updateable in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
othellomy@yahoo.com
 
Posts: n/a

Default views not updateable - 03-23-2007 , 05:06 AM






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.


Reply With Quote
  #2  
Old   
othellomy@yahoo.com
 
Posts: n/a

Default Re: views not updateable - 03-23-2007 , 05:13 AM






On Mar 23, 4:06 pm, othell... (AT) yahoo (DOT) com wrote:
Quote:
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...



Reply With Quote
  #3  
Old   
othellomy@yahoo.com
 
Posts: n/a

Default Re: views not updateable - 03-23-2007 , 05:34 AM



On Mar 23, 4:13 pm, othell... (AT) yahoo (DOT) com wrote:
Quote:
On Mar 23, 4:06 pm, othell... (AT) yahoo (DOT) 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
Quote:
From Base_table
Not Updateable:
Create view view1 as
Select column1, column2
Quote:
From Base_table
Group by column1,column2

I wish there is an easier way than this.



Reply With Quote
  #4  
Old   
Damien
 
Posts: n/a

Default Re: views not updateable - 03-23-2007 , 10:15 AM



On Mar 23, 10:34 am, othell... (AT) yahoo (DOT) com wrote:
Quote:
On Mar 23, 4:13 pm, othell... (AT) yahoo (DOT) com wrote:

On Mar 23, 4:06 pm, othell... (AT) yahoo (DOT) 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



Reply With Quote
  #5  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: views not updateable - 03-23-2007 , 06:05 PM



On 23 Mar 2007 03:13:01 -0700, othellomy (AT) yahoo (DOT) com wrote:

Quote:
On Mar 23, 4:06 pm, othell... (AT) yahoo (DOT) 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


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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.