Skip to content

Instantly share code, notes, and snippets.

@daniel-garcia
Created March 30, 2012 19:39
Show Gist options
  • Save daniel-garcia/2254364 to your computer and use it in GitHub Desktop.
Save daniel-garcia/2254364 to your computer and use it in GitHub Desktop.
generate fragmented table
DELIMITER $$
CREATE PROCEDURE `createfragTable`()
BEGIN
DECLARE ii INT DEFAULT 0;
DROP TABLE IF EXISTS fragme;
CREATE TABLE fragme (
`id` INT NOT NULL AUTO_INCREMENT ,
`col0` BLOB NULL ,
`col1` BLOB NULL ,
`col2` BLOB NULL ,
`col3` BLOB NULL ,
`col4` BLOB NULL ,
`col5` BLOB NULL ,
`col6` BLOB NULL ,
`col7` BLOB NULL ,
`col8` BLOB NULL ,
`col9` BLOB NULL ,
PRIMARY KEY (`id`)
);
-- seed the table
INSERT INTO fragme (col0,col1,col2,col3,col4,col5,col6,col7,col8,col9)
SELECT UUID(), UUID(),UUID(),UUID(),UUID(),UUID(),UUID(),UUID(),UUID(),UUID()
;
WHILE ii <= 20 DO
INSERT INTO fragme (col0,col1,col2,col3,col4,col5,col6,col7,col8,col9)
SELECT col0,col1,col2,col3,col4,col5,col6,col7,col8,col9
FROM fragme
;
SET ii = ii + 1;
END WHILE;
END
$$
DELIMITER ;
call createfragTable();
DELETE FROM fragme
WHERE id % 2 = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment