Thread: A table with two names or table alias

A table with two names or table alias

From
Tk421
Date:
    Can I create a table name alias?
   What i want is to access the same table with two different names. An 
example:
   I've the table CITY with fields code and name. I want to know if i 
can create an alternative name to table CITY, like LOCATION, to make 
possible these two sentences:
      insert into CITY values (10, 'New York');      insert into LOCATION values (11, 'Paris')
   Thank you.


Re: A table with two names or table alias

From
"A. Kretschmer"
Date:
am  Fri, dem 25.07.2008, um 14:12:47 +0200 mailte Tk421 folgendes:
>    Can I create a table name alias?
> 
>    What i want is to access the same table with two different names. An 
> example:
> 
>    I've the table CITY with fields code and name. I want to know if i 
> can create an alternative name to table CITY, like LOCATION, to make 
> possible these two sentences:
> 
>       insert into CITY values (10, 'New York');
>       insert into LOCATION values (11, 'Paris')
> 
>    Thank you.

You can create a VIEW, and if you want to insert data into the view, you
can create rules for that.


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net


Re: A table with two names or table alias

From
"Igor Neyman"
Date:
There are no synonyms in Postgres (like in Oracle).
To implement what you want, you need to use views and rules.
From Postgres docs:
"Currently, views are read only: the system will not allow an insert,
update, or delete on a view. You can get the effect of an updatable view
by creating rules that rewrite inserts, etc. on the view into
appropriate actions on other tables."

Read docs on views and rules.

HTH,
Igor

-----Original Message-----
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Tk421
Sent: Friday, July 25, 2008 8:13 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] A table with two names or table alias
   Can I create a table name alias?
   What i want is to access the same table with two different names. An
example:
   I've the table CITY with fields code and name. I want to know if i
can create an alternative name to table CITY, like LOCATION, to make
possible these two sentences:
      insert into CITY values (10, 'New York');      insert into LOCATION values (11, 'Paris')
   Thank you.

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql