niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » IBM DB2
How do I make a VIEW read-only?
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
Author Message
Serge Rielau
*nix forums Guru


Joined: 29 Apr 2005
Posts: 1583

PostPosted: Wed Feb 16, 2005 10:44 am    Post subject: Re: How do I make a VIEW read-only? Reply with quote

Thiru wrote:
Quote:
I think

grant select on <view name> to user | group <name

will solve the problem.

Correct me if iam wrong.

Cheers,
Thiru
WantedToBeDBA
From an authorization perspective yes. From a locking perspective, no.

When DB2 for LUW compiles a DML statement that happens independent of
authorization.
Only when the statement executes is authorization validated.
Another user with more authorization can execute the same statement
without needing to recompile.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Back to top
Thiru
*nix forums addict


Joined: 20 May 2005
Posts: 80

PostPosted: Wed Feb 16, 2005 8:46 am    Post subject: Re: How do I make a VIEW read-only? Reply with quote

I think

grant select on <view name> to user | group <name>

will solve the problem.

Correct me if iam wrong.

Cheers,
Thiru
WantedToBeDBA
Back to top
Serge Rielau
*nix forums Guru


Joined: 29 Apr 2005
Posts: 1583

PostPosted: Tue Feb 15, 2005 10:30 pm    Post subject: Re: How do I make a VIEW read-only? Reply with quote

Mark A wrote:
Quote:
"Serge Rielau" <srielau@ca.ibm.com> wrote in message
news:37er9aF5ei42iU1@individual.net...

The READ ONLY column properties on typed views was introduced in order
to create subviews with expressions for columns which are natively
updatable in the parent.
The easiest way to make a view READ ONLY is this:

CREATE VIEW v1 AS SEELCT ....FROM ...., TABLE(VALUES (1)) AS A(a);

The optimizer will throw the VALUES(1) out, so it should be harmless.

Cheers
Serge


Serge Rielau


Are you suggesting that no share locks are taken on the real table?


No. I'm suggesting that this makes the view READ ONLY.
Operating on a hunch here w.r.t. OP's question.
There are various clients (and apps, and users, ...) which are rather
sloppy when it comes to defining a cursor as read only.
So any cursor opened on an updatable query will hold a U lock on the row
it positions even if the isolation level is UR.
This trick will make away with the problem. So UR will take no locks.

Cheers
Serge

PS: I learned that some JDBC drivers by default even presume cursors to
be scrollable... now there is a way to wreck performance.

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Back to top
Vincent M
*nix forums Guru


Joined: 22 Feb 2005
Posts: 1332

PostPosted: Tue Feb 15, 2005 7:01 pm    Post subject: Re: How do I make a VIEW read-only? Reply with quote

"Serge Rielau" <srielau@ca.ibm.com> wrote in message
news:37er9aF5ei42iU1@individual.net...
Quote:
The READ ONLY column properties on typed views was introduced in order
to create subviews with expressions for columns which are natively
updatable in the parent.
The easiest way to make a view READ ONLY is this:

CREATE VIEW v1 AS SEELCT ....FROM ...., TABLE(VALUES (1)) AS A(a);

The optimizer will throw the VALUES(1) out, so it should be harmless.

Cheers
Serge

Serge Rielau

Are you suggesting that no share locks are taken on the real table?
Back to top
aj
*nix forums addict


Joined: 28 Jul 2005
Posts: 60

PostPosted: Tue Feb 15, 2005 6:06 pm    Post subject: Re: How do I make a VIEW read-only? Reply with quote

Cool way to do that there, Serge. Plus this helped
me w/ an unrelated thing where I wanted a view to just
return a group of hardcoded values while acting just
like a table (for join purposes).

thanks :)

aj

Serge Rielau wrote:
Quote:
aj wrote:

DB2 WSE 8.1 FP5
Red Hat Linux AS 2.1

I have simple view definition like:

create view B as
select * from A ;

How can I make B READ-ONLY so that no locks are
ever created when people query B?

In the SQL reference doc, under CREATE VIEW, I see
reference with-options, where you can somehow specify
that a column is read-only, but I get syntax errors
when I try to use this. There's no super or sub
table stuff w/ my view or base table - is that what
the doc is referring to?

Any help appreciated.

aj

The READ ONLY column properties on typed views was introduced in order
to create subviews with expressions for columns which are natively
updatable in the parent.
The easiest way to make a view READ ONLY is this:

CREATE VIEW v1 AS SEELCT ....FROM ...., TABLE(VALUES (1)) AS A(a);

The optimizer will throw the VALUES(1) out, so it should be harmless.

Cheers
Serge
Back to top
Serge Rielau
*nix forums Guru


Joined: 29 Apr 2005
Posts: 1583

PostPosted: Tue Feb 15, 2005 4:54 pm    Post subject: Re: How do I make a VIEW read-only? Reply with quote

aj wrote:
Quote:
DB2 WSE 8.1 FP5
Red Hat Linux AS 2.1

I have simple view definition like:

create view B as
select * from A ;

How can I make B READ-ONLY so that no locks are
ever created when people query B?

In the SQL reference doc, under CREATE VIEW, I see
reference with-options, where you can somehow specify
that a column is read-only, but I get syntax errors
when I try to use this. There's no super or sub
table stuff w/ my view or base table - is that what
the doc is referring to?

Any help appreciated.

aj
The READ ONLY column properties on typed views was introduced in order

to create subviews with expressions for columns which are natively
updatable in the parent.
The easiest way to make a view READ ONLY is this:

CREATE VIEW v1 AS SEELCT ....FROM ...., TABLE(VALUES (1)) AS A(a);

The optimizer will throw the VALUES(1) out, so it should be harmless.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Back to top
aj
*nix forums addict


Joined: 28 Jul 2005
Posts: 60

PostPosted: Tue Feb 15, 2005 4:09 pm    Post subject: How do I make a VIEW read-only? Reply with quote

DB2 WSE 8.1 FP5
Red Hat Linux AS 2.1

I have simple view definition like:

create view B as
select * from A ;

How can I make B READ-ONLY so that no locks are
ever created when people query B?

In the SQL reference doc, under CREATE VIEW, I see
reference with-options, where you can somehow specify
that a column is read-only, but I get syntax errors
when I try to use this. There's no super or sub
table stuff w/ my view or base table - is that what
the doc is referring to?

Any help appreciated.

aj
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 3:41 am | All times are GMT
navigation Forum index » Databases » IBM DB2
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts make printer network available Johann Höchtl networking 0 Fri Jul 21, 2006 9:01 am
No new posts hi, I am not able view all the records in the tabel Annam Srinivas MySQL 0 Fri Jul 21, 2006 7:42 am
No new posts Creating relational view for an ODBC result set? antilog@gmail.com Server 0 Fri Jul 21, 2006 5:56 am
No new posts Problems with make-kpkg and skas patch Todd A. Jacobs Debian 0 Fri Jul 21, 2006 12:30 am
No new posts ConfigParser: what read('non-existent-filename') returns ... Danil Dotsenko python 4 Thu Jul 20, 2006 5:50 pm

Proxy | Dutch Bodybuilding Forums | Problem Mortgage | Mortgage Calculator | Bank Credit Cards
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1374s ][ Queries: 20 (0.0540s) ][ GZIP on - Debug on ]