更新按日期分表,多个表添加字段
更新日志表
SET @sql = ‘’;
SELECT GROUP_CONCAT(CONCAT(‘ALTER TABLE ', table_name, '
ADD COLUMN result_total
bigint(20) NULL DEFAULT 0 COMMENT “接口返回数据量”;’) SEPARATOR ’ ')
INTO @sql
FROM information_schema.tables
WHERE table_name LIKE ‘t_dg_service_log_2023%’
AND table_type = ‘BASE TABLE’
AND table_schema = ‘data_service_new’;
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;