CREATE TABLE pgbench_accounts_1 (CHECK (bid >= 1 and bid <= 10)) INHERITS (pgbench_accounts);
CREATE TABLE pgbench_accounts_2 (CHECK (bid >= 11 and bid <= 20)) INHERITS (pgbench_accounts);
CREATE TABLE pgbench_accounts_3 (CHECK (bid >= 21 and bid <= 30)) INHERITS (pgbench_accounts);
CREATE TABLE pgbench_accounts_4 (CHECK (bid >= 31 and bid <= 40)) INHERITS (pgbench_accounts);
CREATE TABLE pgbench_accounts_5 (CHECK (bid >= 41 and bid <= 50)) INHERITS (pgbench_accounts);
CREATE TABLE pgbench_accounts_6 (CHECK (bid >= 51 and bid <= 60)) INHERITS (pgbench_accounts);
CREATE TABLE pgbench_accounts_7 (CHECK (bid >= 61 and bid <= 70)) INHERITS (pgbench_accounts);
CREATE TABLE pgbench_accounts_8 (CHECK (bid >= 71 and bid <= 80)) INHERITS (pgbench_accounts);
CREATE TABLE pgbench_accounts_9 (CHECK (bid >= 81 and bid <= 90)) INHERITS (pgbench_accounts);
CREATE TABLE pgbench_accounts_10 (CHECK (bid >= 91 and bid <= 100)) INHERITS (pgbench_accounts);

WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 1 and bid <= 10 RETURNING *) INSERT INTO pgbench_accounts_1 SELECT * FROM del;
WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 11 and bid <= 20 RETURNING *) INSERT INTO pgbench_accounts_2 SELECT * FROM del;
WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 21 and bid <= 30 RETURNING *) INSERT INTO pgbench_accounts_3 SELECT * FROM del;
WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 31 and bid <= 40 RETURNING *) INSERT INTO pgbench_accounts_4 SELECT * FROM del;
WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 41 and bid <= 50 RETURNING *) INSERT INTO pgbench_accounts_5 SELECT * FROM del;
WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 51 and bid <= 60 RETURNING *) INSERT INTO pgbench_accounts_6 SELECT * FROM del;
WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 61 and bid <= 70 RETURNING *) INSERT INTO pgbench_accounts_7 SELECT * FROM del;
WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 71 and bid <= 80 RETURNING *) INSERT INTO pgbench_accounts_8 SELECT * FROM del;
WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 81 and bid <= 90 RETURNING *) INSERT INTO pgbench_accounts_9 SELECT * FROM del;
WITH del AS (DELETE FROM pgbench_accounts WHERE bid >= 91 and bid <= 100 RETURNING *) INSERT INTO pgbench_accounts_10 SELECT * FROM del;