How can i get mySql column Length/Values

前端 未结 3 1307
一生所求
一生所求 2021-01-25 04:30

I can get column table information with this command, but that don\'t return column Length/Values, how can i get that?

SELECT COLUMN_NAME, DATA_TYPE         


        
3条回答
  •  醉梦人生
    2021-01-25 04:57

    The easiest way to do is using the LEN() function as this example:

    SELECT CustomerName,LEN(Address) as LengthOfAddress
    FROM Customers;
    

    So for your code should be:

    SELECT COLUMN_NAME, LEN(COLUMN_NAME) as NAME_LENGTH, 
    DATA_TYPE, LEN(DATA_TYPE) as DATA_LENGTH 
    FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tableName';
    

    Here you have more information!

提交回复
热议问题