Skip to content

Instantly share code, notes, and snippets.

@alkema
Created August 3, 2011 19:17
Show Gist options
  • Save alkema/1123536 to your computer and use it in GitHub Desktop.
Save alkema/1123536 to your computer and use it in GitHub Desktop.
CREATE TABLE for_ddl LIKE foo;
insert into for_ddl select * from foo WHERE ...;
ALTER TABLE for_ddl DROP INDEX bar;
more ddl...
RENAME TABLE foo TO old_foo;
RENAME TABLE for_ddl TO foo;
DROP TABLE old_foo;
@tinnet
Copy link

tinnet commented Aug 3, 2011

RENAME TABLE foo TO foo_old, foo_new TO foo;
is atomic & transactional, no need to lock

but this is missing the "copy the data part", which is the real problem, no? :)

@alkema
Copy link
Author

alkema commented Aug 3, 2011

yes. updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment