Re: Information about the command SQL " create synonym".

From: Philip Patterson <philip(dot)patterson(at)gmail(dot)com>
To: "Gerald(dot)Laurent(at)bull(dot)net" <Gerald(dot)Laurent(at)bull(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Information about the command SQL " create synonym".
Date: 2005-02-03 19:48:53
Message-ID: eab2c4b905020311486339dba4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, 12 Oct 2004 15:04:14 +0200, Gerald(dot)Laurent(at)bull(dot)net
<Gerald(dot)Laurent(at)bull(dot)net> wrote:
> Hello !
>
> I am trying to find some informations about the SQL command "create
> synonym".
>
> The command "create synonym" does not exit in the Postgres database.
>
> I had tested with the latest version (postgres8.0 beta3) and this command
> is not present.
>
> I supposed that this command "create synnonym" is an extention of the SQL92
> on the other database like Oracle, Informix etc..
>
> Could you say if this command will be implemanted in a future version of a
> postgres database ?
>
> Best regards.
>
>

Hi Gerald.

Much like yourself, I have been searching for a way to create synonyms
in Postgres. I think that I have found a hack / solution to our
problem. Please bare in mind that I have not had an opportunity to
fully test this from every angle, but the basics of SELECT, INSERT,
UPDATE, and DELETE all work just fine.

What I did, was to make use of the Postgres inheritance feature. The
documentation's example uses this to create a new table that adds a
new column/field to an existing table. However it seems quite happy
to let you inherit without changing the structure of the original
table at all. This in turn effectively creates an alias.

For example, if you create a table as follows ...

CREATE TABLE foo (bar int not null);

but you need a synonym called "gerald", then you could do the following ...

CREATE TABLE gerald () INHERITS (foo);

You can now use the object "gerald" to do everything (that I tried)
you want with "foo".

I would love to hear from the developers, or other gurus, if there are
any serious issues with doing this. Will it create any serious
performance problems, or will there be functionality gaps between a
real table and an inherited table that might limit the usefulness of
this workaround?

Best of luck,
Philip

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Boes 2005-02-03 19:56:14 Re: Calendar Function
Previous Message Bradley Miller 2005-02-03 19:04:59 Re: pg_restore problem