473,414 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

How do I make a VIEW read-only?

aj
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
Nov 12 '05 #1
6 13956
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

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
aj
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:
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

Nov 12 '05 #3
"Serge Rielau" <sr*****@ca.ibm.com> wrote in message
news:37*************@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?
Nov 12 '05 #4
Mark A wrote:
"Serge Rielau" <sr*****@ca.ibm.com> wrote in message
news:37*************@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
Nov 12 '05 #5
I think

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

will solve the problem.

Correct me if iam wrong.

Cheers,
Thiru
WantedToBeDBA

Nov 12 '05 #6
Thiru wrote:
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
Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: valexena | last post by:
My attempt to read the view creation code stored in the Oracle data dictionary has encountered a problem. The view code appears to be getting cut off at the end. What have I to do resolve this...
5
by: ScottyBaby | last post by:
Hi, I've run into a curious problem with MS SQL Server 8.0. Using sp_help and SQL Query Analyzer's object browser to view the columns returned by a view, I find that sp_help is reporting stale...
4
by: MD | last post by:
I am trying to create a dynamic SQL statement to create a view. I have a stored procedure, which based on the parameters passed calls different stored procedures. Each of this sub stored procedure...
8
by: Nancy | last post by:
Hi, Guys, I don't know why I can't view some webpages source code by click "View->Source" menu of Browser. These webpage source code can be viewed in same way by using other computers. My OS is...
18
by: Lorem Ipsum | last post by:
interesting! I just found a page in which Explorer's View Source does nothing! How did they do that?
6
by: Eugene | last post by:
Summary: ---------- Updates against UNION ALL view does't do branch elimination, but rather reads all the branches (partitions). The case scenario(DB2 V8.1.4a ESE, AIX 5.2):...
4
by: Pham Nguyen | last post by:
I have two maybe related questions about view state and the life cycle of controls: 1) When does the view state in a control get restored? I thought there was a LoadViewState event that occured...
3
by: Philip Tripp | last post by:
I've read numerous sources stating that view state can be disabled per control, and per page, but can't seem to keep web form controls from remembering their state on a postback. I'm using VS.Net...
0
by: Gian Paolo | last post by:
this is something really i can't find a reason. I have a form with a tabcontrol with tree pages, in the second page there is a Data GRid View. Plus i have a class. When i open the form i...
0
by: pbo | last post by:
Hello, If anyone knows a trick...thanks Philippe I want to create a table view on AS/400 which have a column which is not referenced in a table. With the AS/400 SQL gui, I create the table...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.