move table between schemas

Поиск
Список
Период
Сортировка
Искать

move table between schemas

От:
Frank Bax <fbax@sympatico.ca>
Дата:
Is it possible to move a table from one schema to another (in the same 
database)?

The only way I can think of is to:
	- backup table
	- modify backup file
	- restore from modified backup
	- delete original table

Is there a better/easier way?

Re: move table between schemas

От:
"Sean Davis" <sdavis2@mail.nih.gov>
Дата:
On Tue, Dec 2, 2008 at 8:55 PM, Frank Bax  wrote:
>
> Is it possible to move a table from one schema to another (in the same database)?
>
> The only way I can think of is to:
>        - backup table
>        - modify backup file
>        - restore from modified backup
>        - delete original table
>
> Is there a better/easier way?

ALTER TABLE name
    SET SCHEMA new_schema

http://www.postgresql.org/docs/current/static/sql-altertable.html


Hope that helps.

Sean

Re: move table between schemas

От:
Frank Bax <fbax@sympatico.ca>
Дата:
Sean Davis wrote:
> On Tue, Dec 2, 2008 at 8:55 PM, Frank Bax  wrote:
>> Is it possible to move a table from one schema to another (in the same database)?
>>
>> The only way I can think of is to:
>>        - backup table
>>        - modify backup file
>>        - restore from modified backup
>>        - delete original table
>>
>> Is there a better/easier way?
> 
> ALTER TABLE name
>     SET SCHEMA new_schema
> 
> http://www.postgresql.org/docs/current/static/sql-altertable.html
> 
> 
> Hope that helps.


Yes, very much so; thanks!
FAQ