Jim C. Nasby wrote:
> On Mon, May 22, 2006 at 03:28:39PM -0400, Andrew Dunstan wrote:
>
>> Jim C. Nasby wrote:
>>
>>> BEGIN;
>>> -- Don't do the drop right now, because it might take awhile
>>> ALTER TABLE tablename RENAME TO delete_tablename;
>>> ALTER TABLE temporary_tablename RENAME TO tablename;
>>> COMMIT;
>>> DROP delete_tablename;
>>>
>>>
>>>
>> What if there are dependencies? Might be better to have a view, which
>> everything depends on, and change the view definition from one table to
>> another back and forth.
>>
>
> What dependencies would there be that a view would solve? You can't
> define RI on a view AFAIK...
>
functions, rules, other views ... RI is not the only source of dependencies.
you would do this:
< load table_a >
create or replace view v as select * from table_a;
drop if exists table table_b;
next time around swap table_a and table_b, or you could write some
plpgsql or plperl to do it nicely for you.
cheers
andrew