Markus Schaber <[EMAIL PROTECTED]> writes:
> Andrew Sullivan <[EMAIL PROTECTED]> wrote:
>> CREATE TABLE newschema.newtable AS SELECT * FROM oldschema.oldtable
>> oughta work.
> - The operation is not atomic, thus there may be inserts and updates
> into the old table that get lost while the "CREATE...SELECT...;DROP
> TABLE...;" runs.
You'd deal with that by taking a lock on the old table. Any sort of
catalog-munging solution would have to do the same (though admittedly it
wouldn't need to hold the lock as long).
> Is there any (possibly ugly, fiddling with system tables) atomic way to
> move a table between schemas?
Offhand:
* update table's pg_class.relnamespace field
* update pg_depend entry that links table to namespace
* repeat for table's rowtype (pg_type entry)
* repeat for each index on the table
* repeat for each constraint on the table
Not sure if that's all the places or not...
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly