Jaime Casanova wrote:
> In a galaxy far, far away Bernd wrote:
> The context:
>>so joined views are even not updateable, too.
> I don't find the why of this on the specs and the
> threads about this issue ignore the comment.
In O'Reilly there are also the conditions mentioned a view has to pass
when declaring it updateable (also SQL99):
- The SELECT of the CREATE VIEW command depends only on one table
- UNION, EXCEPT and INTERSECT are not part of the View's SELECT
- No GROUP BY or HAVING
- Pseudo-Columns are forbidden, too (but i think that can improved to
- No Aggregates
- No DISTINCT
so joined views are even not updateable, too.
Well, I haven't checked the specs, but this list is clearly incorrect
from a theoretical point of view (I've been thinking about this recently).
There are two things (AFAICT) you need to be able to do to update (NOTE
- not insert) a view.
1. Identify the underlying table(s) for the updated column(s)
2. Identify (primary) key values for the table(s) being updated.
So - I could have a join listing users and how many email aliases they
have (so sum()) and still update their name, so long as the key for the
users table was present in the view.
Any summarising rules out updates for the summarised tables (because you
no longer have a key available). Similarly, expression/function columns
can't be updated (except in certain special cases).
UNION etc doesn't necessarily mean you can't update, so long as the
underlying table/key can be identified.
For INSERTing to a view, the same rules apply, but obviously you need to
be able to identify table/keys for all columns in the view. This
clearly rules out aggregates etc.
In response to
pgsql-hackers by date
|Next:||From: Dave Hartwig||Date: 2004-12-22 11:33:34|
|Subject: Can't Restart ver 8.0b3 |
|Previous:||From: Mahmoud Taghizadeh||Date: 2004-12-22 09:12:36|
|Subject: strcoll_l an new approach for locale per column|