Maximum size of a Mysql column

Asked

Viewed 478 times

1

Good afternoon, folks! 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 record (then 0)... What can cause this?

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

I accept new suggestions in place of MAX(LENGTH()) haha

  • 2

    Maybe doing a query in the schema table is a solution.

  • how would this query?

1 answer

2

It’s like the Kaduamaral said, you can do this consultation:

SELECT character_maximum_length 
FROM   information_schema.columns 
WHERE  table_name = 'nome_tabela'
  • Okay! Thanks for your help guys, it worked!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.