rename of a view
Hi all,
I got the question: how can I rename a view?
At the first moment, I have had no idea ... and I asked the German guys
at IRC.
They have had no idea too.
Than I just tried: alter table pgview rename to bettername;
that works, but there is no hint at the documentation, that you can
rename a view via alter table.
Is it possible to add a hint for this to the documentation?
Regards,
Susanne
--
Susanne Ebrecht,
52066 Aachen, Germany
Susanne Ebrecht <miracee@miracee.de> writes:
that works, but there is no hint at the documentation, that you can
rename a view via alter table.
It is mentioned someplace (don't remember where). Where would you have
expected to find it?
regards, tom lane
On Thu, 2007-28-06 at 13:31 +0200, Susanne Ebrecht wrote:
Than I just tried: alter table pgview rename to bettername;
that works, but there is no hint at the documentation, that you can
rename a view via alter table.
From the ALTER TABLE reference page: "The RENAME forms change the name
of a table (or an index, sequence, or view) or the name of an individual
column in a table."
Of course, it could be made more obvious...
-Neil
On Thu, Jun 28, 2007 at 10:16:51AM -0400, Tom Lane wrote:
Susanne Ebrecht <miracee@miracee.de> writes:
that works, but there is no hint at the documentation, that you
can rename a view via alter table.It is mentioned someplace (don't remember where). Where would you
have expected to find it?
I'd expect to find it in an ALTER VIEW document.
Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter
Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate
Neil Conway wrote:
On Thu, 2007-28-06 at 13:31 +0200, Susanne Ebrecht wrote:
Than I just tried: alter table pgview rename to bettername;
that works, but there is no hint at the documentation, that you can
rename a view via alter table.From the ALTER TABLE reference page: "The RENAME forms change the name
of a table (or an index, sequence, or view) or the name of an individual
column in a table."Of course, it could be made more obvious...
I looked at \h ALTER TABLE
my system is in German, and there is no hint, that this is for views too.
Using 8.2.4.
Susanne
--
Susanne Ebrecht,
52066 Aachen, Germany
On Fri, Jun 29, 2007 at 11:32:19AM -0700, David Fetter wrote:
On Thu, Jun 28, 2007 at 10:16:51AM -0400, Tom Lane wrote:
Susanne Ebrecht <miracee@miracee.de> writes:
that works, but there is no hint at the documentation, that you
can rename a view via alter table.It is mentioned someplace (don't remember where). Where would you
have expected to find it?I'd expect to find it in an ALTER VIEW document.
Cheers,
D
The attached patch and file implement and document
ALTER [VIEW | SEQUENCE] RENAME TO
The file goes in doc/src/sgml/ref and the patch should just apply to
CVS HEAD.
Thanks to Neil Conway for all the help putting this together :)
Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter
Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate
David Fetter wrote:
pgsql-patches will be more appropriate for a patch. Could you post there
so your patch won't be forget?
The attached patch and file implement and document
ALTER [VIEW | SEQUENCE] RENAME TO
I didn't test your patch, but I think we could disallow ALTER TABLE to
rename sequence and view because we have specific new commands for it or
at least put a NOTICE saying such a thing.
--
Euler Taveira de Oliveira
http://www.timbira.com/
Euler Taveira de Oliveira <euler@timbira.com> writes:
I didn't test your patch, but I think we could disallow ALTER TABLE to
rename sequence and view
There is exactly 0 chance of that happening, because it's always worked
historically.
Personally I don't see a lot of value in this patch at all, but maybe
it is small enough to be justifiable. I am not sure it is complete
however, in the sense of touching everyplace that should be touched,
especially documentation-wise? I mean, its only excuse to live is
that "I expected to find this functionality under $foo", and so I'm
wondering how many values of $foo there are.
regards, tom lane
On Sat, 2007-30-06 at 00:26 -0400, Tom Lane wrote:
There is exactly 0 chance of that happening, because it's always worked
historically.
Agreed, but I think the patch should disallow ALTER VIEW ... RENAME on a
non-view, and ALTER SEQUENCE ... RENAME on a non-sequence.
-Neil
Neil Conway <neilc@samurai.com> writes:
On Sat, 2007-30-06 at 00:26 -0400, Tom Lane wrote:
There is exactly 0 chance of that happening, because it's always worked
historically.
Agreed, but I think the patch should disallow ALTER VIEW ... RENAME on a
non-view, and ALTER SEQUENCE ... RENAME on a non-sequence.
No objection to that; it'd square with our treatment of TYPE and DOMAIN
commands. What I'm wondering though is whether the whole patch has
a reason to live at all, as compared to documenting someplace more
prominent than now that ALTER TABLE works on views & sequences.
regards, tom lane
On Sat, Jun 30, 2007 at 01:36:22AM -0400, Tom Lane wrote:
Neil Conway <neilc@samurai.com> writes:
On Sat, 2007-30-06 at 00:26 -0400, Tom Lane wrote:
There is exactly 0 chance of that happening, because it's always
worked historically.Agreed, but I think the patch should disallow ALTER VIEW ...
RENAME on a non-view, and ALTER SEQUENCE ... RENAME on a
non-sequence.No objection to that; it'd square with our treatment of TYPE and
DOMAIN commands. What I'm wondering though is whether the whole
patch has a reason to live at all, as compared to documenting
someplace more prominent than now that ALTER TABLE works on views &
sequences.
How could it be prominent short of documentation of the thing people
would expect, which is ALTER [SEQUENCE | VIEW] RENAME TO ... ? I
suppose we could document that they're actually done by ALTER TABLE,
but that just seems like a huge POLA violation, along with assuming
way too much knowledge of how sequences and views are implemented.
Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter
Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate
On Sat, 2007-30-06 at 01:36 -0400, Tom Lane wrote:
No objection to that; it'd square with our treatment of TYPE and DOMAIN
commands. What I'm wondering though is whether the whole patch has
a reason to live at all, as compared to documenting someplace more
prominent than now that ALTER TABLE works on views & sequences.
Using ALTER TABLE to rename views and sequences is quite counter-
intuitive, and has been a repeated source of confusion for users. Sure,
we can document that behavior more prominently, but it seems to me it
would be more straightforward in the long-run to just make the system
behave more intuitively in the first place. As an added bonus, it takes
very little new code to implement.
For the ALTER SEQUENCE case, I think it's also a little weird to have an
ALTER SEQUENCE command that modifies some of the properties of a
sequence, but not the sequence's name. While that argument doesn't apply
to ALTER VIEW at the moment, recent history suggests that it may only be
a matter of time before we need to add an ALTER VIEW command anyway...
(for instance, to control the properties of materialized or updateable
views).
-Neil
Neil Conway <neilc@samurai.com> writes:
For the ALTER SEQUENCE case, I think it's also a little weird to have an
ALTER SEQUENCE command that modifies some of the properties of a
sequence, but not the sequence's name. While that argument doesn't apply
to ALTER VIEW at the moment, recent history suggests that it may only be
a matter of time before we need to add an ALTER VIEW command anyway...
OK, that's a fairly convincing argument. Fire away.
(I'm still not sure you found all the relevant places in the
documentation, however.)
regards, tom lane
On Sat, Jun 30, 2007 at 01:48:51AM -0400, Tom Lane wrote:
Neil Conway <neilc@samurai.com> writes:
For the ALTER SEQUENCE case, I think it's also a little weird to
have an ALTER SEQUENCE command that modifies some of the
properties of a sequence, but not the sequence's name. While that
argument doesn't apply to ALTER VIEW at the moment, recent history
suggests that it may only be a matter of time before we need to
add an ALTER VIEW command anyway...OK, that's a fairly convincing argument. Fire away.
(I'm still not sure you found all the relevant places in the
documentation, however.)
Here's a new patch + file. This one allows ALTER [SEQUENCE | VIEW] to
work only on the respective database objects, but permits the old
ALTER TABLE syntax.
Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter
Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate
On Sun, 2007-01-07 at 12:55 -0700, David Fetter wrote:
Here's a new patch + file. This one allows ALTER [SEQUENCE | VIEW] to
work only on the respective database objects, but permits the old
ALTER TABLE syntax.
How about taking a look at the more thorough documentation updates Tom
suggested?
-Neil
On Sun, Jul 01, 2007 at 09:03:45PM -0700, Neil Conway wrote:
On Sun, 2007-01-07 at 12:55 -0700, David Fetter wrote:
Here's a new patch + file. This one allows ALTER [SEQUENCE | VIEW] to
work only on the respective database objects, but permits the old
ALTER TABLE syntax.How about taking a look at the more thorough documentation updates Tom
suggested?
So far I've documented it in the index, the references, and in psql's
tab completion. What other places would you suggest I look?
Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter
Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate
On Sun, 2007-07-01 at 12:55 -0700, David Fetter wrote:
Here's a new patch + file. This one allows ALTER [SEQUENCE | VIEW] to
work only on the respective database objects, but permits the old
ALTER TABLE syntax.
Applied with some fixes. Thanks for the patch. ALTER VIEW ... SET SCHEMA
might be another worthwhile thing to add, for consistency.
-Neil
Neil Conway <neilc@samurai.com> writes:
On Sun, 2007-07-01 at 12:55 -0700, David Fetter wrote:
Here's a new patch + file. This one allows ALTER [SEQUENCE | VIEW] to
work only on the respective database objects, but permits the old
ALTER TABLE syntax.
Applied with some fixes. Thanks for the patch. ALTER VIEW ... SET SCHEMA
might be another worthwhile thing to add, for consistency.
Er, was this on the agenda for 8.3?
regards, tom lane
On Mon, 2007-02-07 at 23:13 -0400, Tom Lane wrote:
Er, was this on the agenda for 8.3?
Well, it seemed fairly harmless to me (no behavioral changes and very
little new code, just syntax), so I didn't see a compelling reason to
delay applying it for a few months. But I can revert it if you'd prefer.
-Neil
Neil Conway wrote:
On Mon, 2007-02-07 at 23:13 -0400, Tom Lane wrote:
Er, was this on the agenda for 8.3?
Well, it seemed fairly harmless to me (no behavioral changes and very
little new code, just syntax), so I didn't see a compelling reason to
delay applying it for a few months. But I can revert it if you'd prefer.
hmm so now we have ALTER VIEW/SEQUENCE commands that can do a bit but
not all of what ALTER TABLE can do (renaming columns of a VIEW or
changing the owner for example).
I agree in principle that having those functionality in ALTER
VIEW/SEQUENCE is a good idea but only bringing in a bit of the required
functionality which still does not solve the "uhm why do I need ALTER
TABLE to manipulate a VIEW" months after the feature freeze sounds a bit
wrong to me :-(
Stefan