Thread: how to modify a view

how to modify a view

From
"J. Manuel Velasco - UBILIBET"
Date:
Hello,

The DB I am using has views. I need to modify the view adding one field to the QUERY that build the query.

When I edit the VIEW and add the field, I get the error that tells me "It's not possible to change columns number in a view"

So, do I need to remove the complete VIEW and create a new one ? Or there is other way to modify the view. ?¿

Thanks in advance,
--
Attachment

Re: how to modify a view

From
Shane Ambler
Date:
J. Manuel Velasco - UBILIBET wrote:
> Hello,
>
> The DB I am using has views. I need to modify the view adding one
> field to the QUERY that build the query.
>
> When I edit the VIEW and add the field, I get the error that tells me
> "It's not possible to change columns number in a view"
>
> So, do I need to remove the complete VIEW and create a new one ? Or
> there is other way to modify the view. ?¿
>
> Thanks in advance, --

Yes - The only way to do it is DROP VIEW... then CREATE VIEW... - the
catch is any other views that depend on the view you wish to drop.


<manual quote>
You can only replace a view with a new query that generates the
identical set of columns (i.e., same column names and data types).
</manual quote>




--

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz

Re: how to modify a view

From
Reece Hart
Date:
On Wed, 2008-05-21 at 02:43 +0930, Shane Ambler wrote:
Yes - The only way to do it is DROP VIEW... then CREATE VIEW... - the
catch is any other views that depend on the view you wish to drop.

Tip: It's sometimes useful to rename an existing view or table to deprecate it. (I use names like _someview_v_20080520.) When you rename a table or view, the definition of any views which depend on them will be updated appropriately. This is particularly handy when you have several layers of views and don't want to break current behavior.

-Reece

-- 
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0

Re: how to modify a view

From
"J. Manuel Velasco - UBILIBET"
Date:
Thank you Shane


All beings be happy,
·_- manou
Shane Ambler escribió:
J. Manuel Velasco - UBILIBET wrote:
Hello,

The DB I am using has views. I need to modify the view adding one
field to the QUERY that build the query.

When I edit the VIEW and add the field, I get the error that tells me
"It's not possible to change columns number in a view"

So, do I need to remove the complete VIEW and create a new one ? Or
there is other way to modify the view. ?¿

Thanks in advance, --

Yes - The only way to do it is DROP VIEW... then CREATE VIEW... - the
catch is any other views that depend on the view you wish to drop.


<manual quote>
You can only replace a view with a new query that generates the
identical set of columns (i.e., same column names and data types).
</manual quote>





--
Attachment