Unix Technical Forum

Proposal for SYNONYMS

This is a discussion on Proposal for SYNONYMS within the pgsql Hackers forums, part of the PostgreSQL category; --> On Thu, 9 Mar 2006, Jonah H. Harris wrote: > 2) For my comprehension, what's the difference between a ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #21 (permalink)  
Old 04-12-2008, 01:34 AM
Kris Jurka
 
Posts: n/a
Default Re: Proposal for SYNONYMS



On Thu, 9 Mar 2006, Jonah H. Harris wrote:

> 2) For my comprehension, what's the difference between a SYNONYM and a
>> single-object (possibly updatable) view?

>
> Not a whole lot actually. If we had updateable views, I'd suggest that
> people change their create synonym syntax to create view.


One key difference would be that synonyms track schema updates, like
adding a column, to the referenced object that a view would not.

Kris Jurka


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #22 (permalink)  
Old 04-12-2008, 01:34 AM
Tom Lane
 
Posts: n/a
Default Re: Proposal for SYNONYMS

Kris Jurka <books@ejurka.com> writes:
> One key difference would be that synonyms track schema updates, like
> adding a column, to the referenced object that a view would not.


That raises a fairly interesting point, actually. What would you expect
to happen here:

CREATE TABLE foo ...;
CREATE SYNONYM bar FOR foo;
CREATE VIEW v AS SELECT * FROM bar;
DROP SYNONYM bar;

With the implementations being proposed, v would effectively be stored
as "SELECT * FROM foo" and thus would be unaffected by the DROP SYNONYM.
Is that what people will expect? Is it what happens in Oracle?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #23 (permalink)  
Old 04-12-2008, 01:34 AM
Ragnar
 
Posts: n/a
Default Re: Proposal for SYNONYMS

On fös, 2006-03-10 at 16:51 -0500, Tom Lane wrote:
> Kris Jurka <books@ejurka.com> writes:
> > One key difference would be that synonyms track schema updates, like
> > adding a column, to the referenced object that a view would not.

>
> That raises a fairly interesting point, actually. What would you expect
> to happen here:
>
> CREATE TABLE foo ...;
> CREATE SYNONYM bar FOR foo;
> CREATE VIEW v AS SELECT * FROM bar;
> DROP SYNONYM bar;
>
> With the implementations being proposed, v would effectively be stored
> as "SELECT * FROM foo" and thus would be unaffected by the DROP SYNONYM.
> Is that what people will expect? Is it what happens in Oracle?



At least on Oracle8, you could create a synonym on a
non-existing table, so if table FOO does not exist:

CREATE SYNONYM BAR FOR FOO; -- no error
SELECT * FROM BAR; -- error "synonym translation is no longuer valid"
CREATE TABLE FOO (a varchar2(10));
INSERT INTO FOO VALUES ('a');
SELECT * FROM BAR; -- no error
CREATE VIEW X AS SELECT * FROM BAR;
SELECT * FROM X; -- no error
DROP SYNONYM X; -- no error
SELECT * FROM BAR; -- error

gnari



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:31 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com