UPDATE mytable SET mycolumn= LTRIM(RTRIM(mycolumn));
works fine on trimming columns removing trailer spaces, but how can i adjust it to trim all column
Since the question asks for the whole database, here is the script that generates the required SQL. I skip the auto execute, execute it as you like.
-- Set your database name here
SET @my_database:='YOUR_DB_NAME';
SET SESSION group_concat_max_len = 1000000;
SELECT
CONCAT('UPDATE `', @my_database, '`.`', TABLE_NAME,
'` SET ', GROUP_CONCAT(
CONCAT('`', COLUMN_NAME, '` = TRIM(`', COLUMN_NAME, '`)')
ORDER BY ORDINAL_POSITION ASC),
';') AS `query`
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_SCHEMA = @my_database
GROUP BY TABLE_NAME
ORDER BY TABLE_NAME ASC;
@ZweiStein Thanks.