Created
March 28, 2020 11:59
-
-
Save schelmo/4b4954b7137199aa1058681ce41d145a to your computer and use it in GitHub Desktop.
convert all innodb tables to dynamic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
umask 0177 | |
temp_file=$(mktemp) | |
trap 'rm -f -- "$temp_file"' INT TERM HUP EXIT | |
read -sp 'mysql root password: ' passvar | |
echo " | |
[client] | |
user=root | |
password='${passvar}' | |
" > $temp_file | |
for table in $( | |
mariadb \ | |
--defaults-extra-file="$temp_file" \ | |
--batch --skip-column-names \ | |
--execute=" | |
SELECT CONCAT('\`', TABLE_SCHEMA, '\`', '.', '\`', TABLE_NAME, '\`') | |
FROM information_schema.TABLES | |
WHERE ENGINE = 'InnoDB' | |
AND ROW_FORMAT IN('Redundant', 'Compact') | |
AND TABLE_NAME NOT IN( | |
'SYS_DATAFILES', 'SYS_FOREIGN', | |
'SYS_FOREIGN_COLS', 'SYS_TABLESPACES', | |
'SYS_VIRTUAL', 'SYS_ZIP_DICT', | |
'SYS_ZIP_DICT_COLS' | |
) | |
AND TABLE_SCHEMA NOT IN( | |
'piwik_stats', 'mysql' | |
) | |
;" | |
) | |
do | |
alter_sql="ALTER TABLE ${table} ROW_FORMAT=DYNAMIC;"; | |
echo $alter_sql | |
mariadb --defaults-extra-file="$temp_file" --execute="${alter_sql}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
idea from here https://blog.basilgohar.com/2019/11/10/upgrade-mariadb-table-row-formats-to-dynamic/