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

Information about the command SQL " create synonym".

From
Gerald.Laurent@bull.net
Date:
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.



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

From
Peter Eisentraut
Date:
Gerald.Laurent@bull.net wrote:
> Could you say if this command will be implemanted in a future version
> of a postgres database ?

I'm not currently aware of any concrete proposals to implement this 
feature, but previous discussion has not shown any strong resistance 
against the concept.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/



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

From
Philip Patterson
Date:
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


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

From
Karsten Hilbert
Date:
> 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.
...
> What I did, was to make use of the Postgres inheritance feature.

> This in turn effectively creates an alias:

> 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);

> I would love to hear from the developers, or other gurus, if there are
> any serious issues with doing this.
Primary keys and foreign keys will likely show unexpected
behaviour (as in being out of sync between foo and gerald and
any other "alias" child tables of foo).

Karsten
-- 
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346