mysql check collation of a table

前端 未结 4 1834
无人及你
无人及你 2020-12-08 18:18

How can I see what collation a table has? I.E. I want to see:

+-----------------------------+
|  table  |     collation     |
|-----------------------------|         


        
4条回答
  •  醉梦人生
    2020-12-08 18:41

    You can also query INFORMATION_SCHEMA.TABLES and get the collation for a specific table:

    SELECT TABLE_SCHEMA
        , TABLE_NAME
        , TABLE_COLLATION 
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_NAME = 't_name';
    

    that gives a much more readable output in contrast to SHOW TABLE STATUS that contains a lot of irrelevant information.


    Note that collation can also be applied to columns (which might have a different collation than the table itself). To fetch the columns' collation for a particular table, you can query INFORMATION_SCHEMA.COLUMNS:

    SELECT TABLE_SCHEMA 
        , TABLE_NAME 
        , COLUMN_NAME 
        , COLLATION_NAME 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 't_name';
    

提交回复
热议问题