On Tue, 12 Oct 2004 15:04:14 +0200, Gerald.Laurent@bull.net
<Gerald.Laurent@bull.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