Skip to content

Instantly share code, notes, and snippets.

@dasl-
Last active September 24, 2019 19:35
Show Gist options
  • Save dasl-/3eb67edf32ae01062a3a045ed344d6e9 to your computer and use it in GitHub Desktop.
Save dasl-/3eb67edf32ae01062a3a045ed344d6e9 to your computer and use it in GitHub Desktop.
-- unsharded database
CREATE TABLE `shops_index` (
`shop_id` bigint(20) unsigned NOT NULL,
`shop_shard` int(11) NOT NULL,
`name` varchar(100) DEFAULT NULL,
PRIMARY KEY (`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
USE `index_test`;
INSERT INTO shops_index (shop_id, shop_shard) VALUES(15, 15);
USE `shard_test:-80`;
INSERT INTO shop_data (shop_id, k, v) VALUES(1, 'a', 'a');
-- sharded database
CREATE TABLE `shop_data` (
`shop_id` bigint(20) unsigned NOT NULL,
`k` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`v` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`shop_id`, `k`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment