First variant
SELECT CONCAT(GROUP_CONCAT(
CONCAT('(SELECT \'',COLUMN_NAME,'\' AS `column`, MAX(CHAR_LENGTH(`',COLUMN_NAME,'`)) AS `max_length`, MIN(CHAR_LENGTH(`',COLUMN_NAME,'`)) AS `min_length` ',
'FROM `',TABLE_SCHEMA,'`.`',TABLE_NAME, '`)')
SEPARATOR ' UNION ALL '), ';') AS sql_query
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'DB_NAME' AND TABLE_NAME = 'TABLE_NAME';
Change DB_NAME and TABLE_NAME
see diff lenght vs char_length
Second variant
SET @db_Name = 'DB';
SET @tb_name = 'table';
SET @sql = NULL;
SELECT
GROUP_CONCAT(
CONCAT('MAX(CHAR_LENGTH(', COLUMN_NAME, ')) AS `', COLUMN_NAME, '`')
) INTO @sql
FROM information_schema.columns
WHERE TABLE_NAME = @tb_name AND
TABLE_SCHEMA = @db_Name
order by ORDINAL_POSITION asc;
SET @sql = CONCAT('SELECT ',@sql, 'FROM ', @tb_name);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
The longest string returned by GROUP_CONCAT() is 1024 by default. Because of that you need to increase this limit.
SET group_concat_max_len = 1024;
Original https://kb.vmware.com/s/article/2042141 Backing up ESXi host configuration data To synchronize the configuration changed with persistent…
vCenter Converter Standalone 6.6.0 download (далее…)
VMware remote console (VMRC) 12.0.5 download Last version: VMware Remote Console 12.0.5 28 NOV 2023…
SELECT col_sizes.TABLE_SCHEMA, col_sizes.TABLE_NAME, SUM(col_sizes.col_size) AS EST_MAX_ROW_SIZE FROM ( SELECT cols.TABLE_SCHEMA, cols.TABLE_NAME, cols.COLUMN_NAME, CASE cols.DATA_TYPE WHEN…
UPDATE DB SET column = DATE(STR_TO_DATE(column, '%Y-%d-%m')) WHERE DATE(STR_TO_DATE(column, '%d-%m-%Y')) <> '0000-00-00'
echo 1 > /sys/class/block/sda/device/rescan #maybe run under root> sudo fdisk /dev/sda2 > d > 2…