Suppose, I have a table foo, which contains some statistics that are computed every now and then. It is heavily used by other queries.
That's why I want to compute more recent statistics in foo_new and swap them when computation is ready.
I could do
ALTER TABLE foo RENAME foo_tmp;
ALTER TABLE foo_new RENAME foo;
but what happens if a query needs table foo inbetween those two lines when there is no table foo? I guess I have to lock it somehow... or is there another way to do it?
tableXthat has got parent constraint referencingfoo. After this RENAME it will be now referencingfoo_oldbut if there are no constraints referencingfoothen you should be OK... – Marcin Wasiluk Jan 17 '17 at 11:23FOREIGN KEYs. – Rick James Apr 04 '17 at 20:32