schema_explorer_reshard_script
Generates a DBA-ready SQL script to change a table’s shard key: builds a replacement table, copies data, checks row count and skew, and swaps tables.
Instructions
"Change shard key…": a SQL script for a DBA (nothing runs). CREATE TABLE __reshard
from the real SHOW CREATE TABLE with only the SHARD KEY replaced, INSERT … SELECT, a row-count and skew check, the
rename swap and a commented-out DROP of the old table, with warnings filled in for this table (size, pipelines,
views, grants, duration). Read-only (logic and docs in ..reshard).
Args:
database: Database (case-sensitive).
table: Table (case-sensitive).
columns: The new shard key's columns, as the table spells them.
simulation: The simulation result's numbers (rsd_pct, current_rsd_pct, elapsed_ms, fraction,
partition_count) for the header and the duration estimate; optional.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | ||
| columns | Yes | ||
| database | Yes | ||
| simulation | No |