Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
START TRANSACTION ;
ALTER TABLE schema_name.table_name RENAME TO table_name_old;
CREATE TABLE schema_name.table_name_new
-- Creation statement
;
INSERT INTO schema_name.table_name_new (
SELECT
*
FROM schema_name.table_name_old
);
ALTER TABLE schema_name.table_name_new RENAME TO table_name;
DROP TABLE schema_name.table_name_old;
ROLLBACK ;
COMMIT ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment