Maximum size of a MySQL column

1

Good afternoon, everyone! I have a question ...

I want to get the maximum size of each column of a table, so I'm using

SELECT MAX(LENGTH(nome_coluna_1)), MAX(LENGTH(nome_coluna_2)).... FROM nome_tabela;

The problem is that some columns come with the correct value of their size and others come with the size of the registry (logo 0) ... What can cause this?

Note: It is a table with 120 columns and all are VARCHAR

I accept new suggestions instead of MAX (LENGTH ()) haha

    
asked by anonymous 14.08.2015 / 22:06

1 answer

1

As KaduAmaral said, you can do this query:

SELECT character_maximum_length 
FROM   information_schema.columns 
WHERE  table_name = 'nome_tabela'
    
15.08.2015 / 01:12