CREATE TABLE stats_rename1 (a INT, PRIMARY KEY (a))
ENGINE=INNODB STATS_PERSISTENT=1;
INSERT INTO mysql.innodb_table_stats
SELECT
database_name,
'stats_rename2' AS table_name,
last_update,
123 AS n_rows,
clustered_index_size,
sum_of_other_index_sizes
FROM mysql.innodb_table_stats
WHERE table_name = 'stats_rename1';
INSERT INTO mysql.innodb_index_stats 
SELECT
database_name,
'stats_rename2' AS table_name,
index_name,
last_update,
stat_name,
567 AS stat_value,
sample_size,
stat_description
FROM mysql.innodb_index_stats
WHERE table_name = 'stats_rename1';
SELECT table_name, n_rows
FROM mysql.innodb_table_stats
WHERE table_name IN ('stats_rename1', 'stats_rename2');
table_name	stats_rename1
n_rows	0
table_name	stats_rename2
n_rows	123
SELECT table_name, index_name, stat_name, stat_value
FROM mysql.innodb_index_stats
WHERE table_name IN ('stats_rename1', 'stats_rename2');
table_name	stats_rename1
index_name	PRIMARY
stat_name	n_diff_pfx01
stat_value	0
table_name	stats_rename1
index_name	PRIMARY
stat_name	n_leaf_pages
stat_value	1
table_name	stats_rename1
index_name	PRIMARY
stat_name	size
stat_value	1
table_name	stats_rename2
index_name	PRIMARY
stat_name	n_diff_pfx01
stat_value	567
table_name	stats_rename2
index_name	PRIMARY
stat_name	n_leaf_pages
stat_value	567
table_name	stats_rename2
index_name	PRIMARY
stat_name	size
stat_value	567
RENAME TABLE stats_rename1 TO stats_rename2;
SELECT table_name, n_rows
FROM mysql.innodb_table_stats
WHERE table_name IN ('stats_rename1', 'stats_rename2');
table_name	stats_rename2
n_rows	0
SELECT table_name, index_name, stat_name, stat_value
FROM mysql.innodb_index_stats
WHERE table_name IN ('stats_rename1', 'stats_rename2');
table_name	stats_rename2
index_name	PRIMARY
stat_name	n_diff_pfx01
stat_value	0
table_name	stats_rename2
index_name	PRIMARY
stat_name	n_leaf_pages
stat_value	1
table_name	stats_rename2
index_name	PRIMARY
stat_name	size
stat_value	1
DROP TABLE stats_rename2;
