更新时间:2023-02-08 16:30:23
晚了几年,但可能会帮助其他人: 此代码修剪表"your_table"的所有字段. 可以扩展为以相同的方式在整个数据库上工作....
Some years late, but might help others: This code trims all fields of a the table "your_table". Could be expanded to work on the whole database in the same way....
SET SESSION group_concat_max_len = 1000000;
select concat('update your_table set ',group_concat(concat('`',COLUMN_NAME, '` = trim(`',COLUMN_NAME,'`)')),';')
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'your_table'
into @trimcmd;
prepare s1 from @trimcmd;
execute s1;
DEALLOCATE PREPARE s1;