Skip to content

Instantly share code, notes, and snippets.

@choplin
Created October 11, 2013 06:54
Show Gist options
  • Select an option

  • Save choplin/6930600 to your computer and use it in GitHub Desktop.

Select an option

Save choplin/6930600 to your computer and use it in GitHub Desktop.
-- 準備
psql1 $ create table foo(v text);
psql1 $ create table bar(v text);
psql1 $ insert into foo values ('foo');
psql1 $ insert into tmp values ('bar');
-- swap: bar -> foo, foo -> bar
psql1 $ begin;
psql2 $ begin;
psql1 $ alter table foo rename to tmp;
psql2 $ select * from foo;
psql1 $ alter table bar rename to foo;
psql1 $ alter table tmp rename to bar;
psql1 $ commit;
-- 9.1
v
-----
foo
(1 row)
-- 9.2
v
-----
bar
(1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment