Thread: Table symbolic link

Table symbolic link

From
"Campbell, Lance"
Date:

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

 

Re: Table symbolic link

From
Craig James
Date:
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.
---------------------------------

Re: Table symbolic link

From
Victor Yegorov
Date:
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:


--
Victor Y. Yegorov

Re: Table symbolic link

From
Joe Conway
Date:
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


Attachment

Re: Table symbolic link

From
Thomas Kellerer
Date:
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"


Re: Table symbolic link

From
Scott Whitney
Date:

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

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/ 

Re: Table symbolic link

From
Steve Crawford
Date:
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


Re: Table symbolic link

From
Payal Singh
Date:
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.
---------------------------------

Re: Table symbolic link

From
"Campbell, Lance"
Date:

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

 

Re: Table symbolic link

From
Albe Laurenz
Date:
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