pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Table symbolic link
10+ messages / 9 participants
[nested] [flat]

* Table symbolic link
@ 2016-05-18 14:31  Campbell, Lance <lance@illinois.edu>
  0 siblings, 6 replies; 10+ messages in thread

From: Campbell, Lance @ 2016-05-18 14:31 UTC (permalink / raw)
  To: pgsql-admin

PostgreSQL 9.5.x

I have 16 web applications using a single database.  Some of the tables in the database are used by many of the applications.  I wanted to rename a particular table.  The issue is that I would have to change every application then stop all the applications and then redeploy them after renaming the table to the new name.

The better strategy would be to rename the table to the new name and add a symbolic table that link to the new table name.  Then as I make changes to each application I can point them to the new name.  Maybe in a year I could delete the symbolic table name.

Is this possible?  I have not seen a symbolic table name feature but I thought I would ask.

If this is not currently possible it might be something to consider adding.

Thanks,

Lance
Web Services @ University of Illinois

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Table symbolic link
@ 2016-05-18 14:36  Craig James <cjames@emolecules.com>
  parent: Campbell, Lance <lance@illinois.edu>
  5 siblings, 1 reply; 10+ messages in thread

From: Craig James @ 2016-05-18 14:36 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; +Cc: pgsql-admin

begin;
alter table foo rename to bar;
create view foo as select * from bar;
commit;


On Wed, May 18, 2016 at 7:31 AM, Campbell, Lance <lance@illinois.edu> wrote:

> PostgreSQL 9.5.x
>
>
>
> I have 16 web applications using a single database.  Some of the tables in
> the database are used by many of the applications.  I wanted to rename a
> particular table.  The issue is that I would have to change every
> application then stop all the applications and then redeploy them after
> renaming the table to the new name.
>
>
>
> The better strategy would be to rename the table to the new name and add a
> symbolic table that link to the new table name.  Then as I make changes to
> each application I can point them to the new name.  Maybe in a year I could
> delete the symbolic table name.
>
>
>
> Is this possible?  I have not seen a symbolic table name feature but I
> thought I would ask.
>
>
>
> If this is not currently possible it might be something to consider
> adding.
>
>
>
> Thanks,
>
>
>
> Lance
>
> Web Services @ University of Illinois
>
>
>



-- 
---------------------------------
Craig A. James
Chief Technology Officer
eMolecules, Inc.
---------------------------------

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Table symbolic link
@ 2016-05-18 14:37  Victor Yegorov <vyegorov@gmail.com>
  parent: Campbell, Lance <lance@illinois.edu>
  5 siblings, 0 replies; 10+ messages in thread

From: Victor Yegorov @ 2016-05-18 14:37 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; +Cc: pgsql-admin

2016-05-18 17:31 GMT+03:00 Campbell, Lance <lance@illinois.edu>:

> Is this possible?  I have not seen a symbolic table name feature but I
> thought I would ask.


You can create a view on top of a renamed table:
http://www.postgresql.org/docs/current/interactive/sql-createview.html


-- 
Victor Y. Yegorov

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Table symbolic link
@ 2016-05-18 14:37  Joe Conway <mail@joeconway.com>
  parent: Campbell, Lance <lance@illinois.edu>
  5 siblings, 1 reply; 10+ messages in thread

From: Joe Conway @ 2016-05-18 14:37 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; pgsql-admin

On 05/18/2016 10:31 AM, Campbell, Lance wrote:
> The better strategy would be to rename the table to the new name and add
> a symbolic table that link to the new table name.  Then as I make
> changes to each application I can point them to the new name.  Maybe in
> a year I could delete the symbolic table name.
> 
> Is this possible?  I have not seen a symbolic table name feature but I
> thought I would ask.

See CREATE VIEW:
http://www.postgresql.org/docs/9.5/interactive/sql-createview.html

HTH,

Joe

-- 
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development

Attachments:

  signature.asc (application/pgp-signature, 835B) download

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Table symbolic link
@ 2016-05-18 14:37  Payal Singh <payal@omniti.com>
  parent: Craig James <cjames@emolecules.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Payal Singh @ 2016-05-18 14:37 UTC (permalink / raw)
  To: Lance Campbell <lance@illinois.edu>; +Cc: pgsql-admin

Can this be done with views?

Payal Singh,
Database Administrator,
OmniTI Computer Consulting Inc.
Phone: 240.646.0770 x 253

On Wed, May 18, 2016 at 10:36 AM, Craig James <cjames@emolecules.com> wrote:

> begin;
> alter table foo rename to bar;
> create view foo as select * from bar;
> commit;
>
>
> On Wed, May 18, 2016 at 7:31 AM, Campbell, Lance <lance@illinois.edu>
> wrote:
>
>> PostgreSQL 9.5.x
>>
>>
>>
>> I have 16 web applications using a single database.  Some of the tables
>> in the database are used by many of the applications.  I wanted to rename a
>> particular table.  The issue is that I would have to change every
>> application then stop all the applications and then redeploy them after
>> renaming the table to the new name.
>>
>>
>>
>> The better strategy would be to rename the table to the new name and add
>> a symbolic table that link to the new table name.  Then as I make changes
>> to each application I can point them to the new name.  Maybe in a year I
>> could delete the symbolic table name.
>>
>>
>>
>> Is this possible?  I have not seen a symbolic table name feature but I
>> thought I would ask.
>>
>>
>>
>> If this is not currently possible it might be something to consider
>> adding.
>>
>>
>>
>> Thanks,
>>
>>
>>
>> Lance
>>
>> Web Services @ University of Illinois
>>
>>
>>
>
>
>
> --
> ---------------------------------
> Craig A. James
> Chief Technology Officer
> eMolecules, Inc.
> ---------------------------------
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Table symbolic link
@ 2016-05-18 14:38  Scott Whitney <scott@journyx.com>
  parent: Campbell, Lance <lance@illinois.edu>
  5 siblings, 0 replies; 10+ messages in thread

From: Scott Whitney @ 2016-05-18 14:38 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; pgsql-admin

Can't you use a simple updateable view? I think a view as "select * from table" would qualify, right?


http://www.postgresql.org/docs/9.5/static/sql-createview.html<http://www.postgresql.org/docs/9.3/...;

[http://www.postgresql.org/media/img/docs/hdr_logo.png]<http://www.postgresql.org/docs/9.3/static/sql-createview.html;

PostgreSQL: Documentation: 9.3: CREATE VIEW<http://www.postgresql.org/docs/9.3/static/sql-createview.html;
www.postgresql.org
Description. CREATE VIEW defines a view of a query. The view is not physically materialized. Instead, the query is run every time the view is referenced in a query.





________________________________
From: pgsql-admin-owner@postgresql.org <pgsql-admin-owner@postgresql.org> on behalf of Campbell, Lance <lance@illinois.edu>
Sent: Wednesday, May 18, 2016 9:31 AM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] Table symbolic link


PostgreSQL 9.5.x



I have 16 web applications using a single database.  Some of the tables in the database are used by many of the applications.  I wanted to rename a particular table.  The issue is that I would have to change every application then stop all the applications and then redeploy them after renaming the table to the new name.



The better strategy would be to rename the table to the new name and add a symbolic table that link to the new table name.  Then as I make changes to each application I can point them to the new name.  Maybe in a year I could delete the symbolic table name.



Is this possible?  I have not seen a symbolic table name feature but I thought I would ask.



If this is not currently possible it might be something to consider adding.



Thanks,



Lance

Web Services @ University of Illinois




Journyx, Inc.
7600 Burnet Road #300
Austin, TX 78757
www.journyx.com

p 512.834.8888
f 512-834-8858

Do you receive our promotional emails? You can subscribe or unsubscribe to those emails at http://go.journyx.com/emailPreference/e/4932/714/

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Table symbolic link
@ 2016-05-18 14:38  Thomas Kellerer <spam_eater@gmx.net>
  parent: Campbell, Lance <lance@illinois.edu>
  5 siblings, 0 replies; 10+ messages in thread

From: Thomas Kellerer @ 2016-05-18 14:38 UTC (permalink / raw)
  To: pgsql-admin

Campbell, Lance schrieb am 18.05.2016 um 16:31:
> PostgreSQL 9.5.x
> 
> I have 16 web applications using a single database. Some of the
> tables in the database are used by many of the applications. I wanted
> to rename a particular table. The issue is that I would have to
> change every application then stop all the applications and then
> redeploy them after renaming the table to the new name.
> 
> The better strategy would be to rename the table to the new name and
> add a symbolic table that link to the new table name. Then as I make
> changes to each application I can point them to the new name. Maybe
> in a year I could delete the symbolic table name.
> 

Create a view with the old name that does a "select * from new_table_name" 




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



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Table symbolic link
@ 2016-05-18 14:39  Steve Crawford <scrawford@pinpointresearch.com>
  parent: Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Steve Crawford @ 2016-05-18 14:39 UTC (permalink / raw)
  To: Joe Conway <mail@joeconway.com>; +Cc: Campbell, Lance <lance@illinois.edu>; pgsql-admin

As others mentioned, you can create a view. But depending on they types of
updates you do, other views that already exist on that table, triggers, and
the version of PostgreSQL among other issues it may not be a viable option.

Cheers,
Steve

On Wed, May 18, 2016 at 7:37 AM, Joe Conway <mail@joeconway.com> wrote:

> On 05/18/2016 10:31 AM, Campbell, Lance wrote:
> > The better strategy would be to rename the table to the new name and add
> > a symbolic table that link to the new table name.  Then as I make
> > changes to each application I can point them to the new name.  Maybe in
> > a year I could delete the symbolic table name.
> >
> > Is this possible?  I have not seen a symbolic table name feature but I
> > thought I would ask.
>
> See CREATE VIEW:
> http://www.postgresql.org/docs/9.5/interactive/sql-createview.html
>
> HTH,
>
> Joe
>
> --
> Crunchy Data - http://crunchydata.com
> PostgreSQL Support for Secure Enterprises
> Consulting, Training, & Open Source Development
>
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Table symbolic link
@ 2016-05-18 14:41  Campbell, Lance <lance@illinois.edu>
  parent: Steve Crawford <scrawford@pinpointresearch.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Campbell, Lance @ 2016-05-18 14:41 UTC (permalink / raw)
  To: 'Steve Crawford' <scrawford@pinpointresearch.com>; Joe Conway <mail@joeconway.com>; +Cc: pgsql-admin

I did not even think about a table view.  I use them very rarely.  I also don’t do update, insert or delete on the view I have.

Thanks a lot.  That was really helpful.

Lance

From: Steve Crawford [mailto:scrawford@pinpointresearch.com]
Sent: Wednesday, May 18, 2016 9:40 AM
To: Joe Conway <mail@joeconway.com>
Cc: Campbell, Lance <lance@illinois.edu>; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Table symbolic link

As others mentioned, you can create a view. But depending on they types of updates you do, other views that already exist on that table, triggers, and the version of PostgreSQL among other issues it may not be a viable option.

Cheers,
Steve

On Wed, May 18, 2016 at 7:37 AM, Joe Conway <mail@joeconway.com<mailto:mail@joeconway.com>> wrote:
On 05/18/2016 10:31 AM, Campbell, Lance wrote:
> The better strategy would be to rename the table to the new name and add
> a symbolic table that link to the new table name.  Then as I make
> changes to each application I can point them to the new name.  Maybe in
> a year I could delete the symbolic table name.
>
> Is this possible?  I have not seen a symbolic table name feature but I
> thought I would ask.

See CREATE VIEW:
http://www.postgresql.org/docs/9.5/interactive/sql-createview.html<https://urldefense.proofpoint....;

HTH,

Joe

--
Crunchy Data - http://crunchydata.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__crunchydata.com&d=...;
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Table symbolic link
@ 2016-05-18 14:57  Albe Laurenz <laurenz.albe@wien.gv.at>
  parent: Campbell, Lance <lance@illinois.edu>
  5 siblings, 0 replies; 10+ messages in thread

From: Albe Laurenz @ 2016-05-18 14:57 UTC (permalink / raw)
  To: 'Campbell, Lance *EXTERN*' <lance@illinois.edu>; pgsql-admin

Lance Campbell wrote:
> I have 16 web applications using a single database.  Some of the tables in the database are used by
> many of the applications.  I wanted to rename a particular table.  The issue is that I would have to
> change every application then stop all the applications and then redeploy them after renaming the
> table to the new name.
> 
> The better strategy would be to rename the table to the new name and add a symbolic table that link to
> the new table name.  Then as I make changes to each application I can point them to the new name.
> Maybe in a year I could delete the symbolic table name.
> 
> Is this possible?  I have not seen a symbolic table name feature but I thought I would ask.
> 
> If this is not currently possible it might be something to consider adding.

You can do that with a view:

BEGIN;
ALTER TABLE oldname RENAME TO newname;
CREATE VIEW oldname AS SELECT * FROM newname;
COMMIT;

Yours,
Laurenz Albe

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


^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2016-05-18 14:57 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-05-18 14:31 Table symbolic link Campbell, Lance <lance@illinois.edu>
2016-05-18 14:36 ` Craig James <cjames@emolecules.com>
2016-05-18 14:37   ` Payal Singh <payal@omniti.com>
2016-05-18 14:37 ` Victor Yegorov <vyegorov@gmail.com>
2016-05-18 14:37 ` Joe Conway <mail@joeconway.com>
2016-05-18 14:39   ` Steve Crawford <scrawford@pinpointresearch.com>
2016-05-18 14:41     ` Campbell, Lance <lance@illinois.edu>
2016-05-18 14:38 ` Scott Whitney <scott@journyx.com>
2016-05-18 14:38 ` Thomas Kellerer <spam_eater@gmx.net>
2016-05-18 14:57 ` Albe Laurenz <laurenz.albe@wien.gv.at>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox