MySQL 的Comment命令行下面在哪里看?我用MySql Administrator看是乱码

解决方案 »

  1.   

    你查表的comment:
     select table_comment from information_schema.tables;查字段的: select column_comment from information_schema.columns;
      

  2.   

    MYSQL版本?
    检查一下字符集设置
    show variables like 'char%'; 
      

  3.   

    mysql> show create table t_iorikingdom;
    +---------------+---------------------------------------------------------------
    | Table         | Create Table
    +---------------+---------------------------------------------------------------
    | t_iorikingdom | CREATE TABLE `t_iorikingdom` (
      `id` int(11) DEFAULT NULL COMMENT 'comment for id',
      `f1` char(1) DEFAULT NULL COMMENT 'comment for f1'
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='comment for table' |
    +---------------+---------------------------------------------------------------
    1 row in set (0.00 sec)mysql>
    mysql> show full columns from t_iorikingdom;
    +-------+---------+-------------------+------+-----+----....-----+----------------+
    | Field | Type    | Collation         | Null | Key | Def....     | Comment        |
    +-------+---------+-------------------+------+-----+----....-----+----------------+
    | id    | int(11) | NULL              | YES  |     | NUL....nces | comment for id |
    | f1    | char(1) | latin1_swedish_ci | YES  |     | NUL....nces | comment for f1 |
    +-------+---------+-------------------+------+-----+----....-----+----------------+
    2 rows in set (0.00 sec)mysql>
    mysql> show table status like 't_iorikingdom';
    +---------------+--------+---------+------....----------------+-------------------+
    | Name          | Engine | Version | Row_f.... Create_options | Comment           |
    +---------------+--------+---------+------....----------------+-------------------+
    | t_iorikingdom | InnoDB |      10 | Compa....                | comment for table |
    +---------------+--------+---------+------....----------------+-------------------+
    1 row in set (0.00 sec)mysql>
      

  4.   

    中文估计是你的字符集设置了。mysql administrator 用得应该是utf8mysql> show create table t_iorikingdom;
    +---------------+---------------------------------------------------------------
    | Table         | Create Table
    +---------------+---------------------------------------------------------------
    | t_iorikingdom | CREATE TABLE `t_iorikingdom` (
      `id` int(11) DEFAULT NULL COMMENT 'comment for id汉字',
      `f1` char(1) DEFAULT NULL COMMENT 'comment for f1汉字'
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='comment for table汉字' |
    +---------------+---------------------------------------------------------------
    1 row in set (0.06 sec)mysql>  show full columns from t_iorikingdom;
    +-------+---------+-------------------+------+-----+-------....----+--------------------+
    | Field | Type    | Collation         | Null | Key | Defaul....    | Comment            |
    +-------+---------+-------------------+------+-----+-------....----+--------------------+
    | id    | int(11) | NULL              | YES  |     | NULL  ....ces | comment for id汉字 |
    | f1    | char(1) | latin1_swedish_ci | YES  |     | NULL  ....ces | comment for f1汉字 |
    +-------+---------+-------------------+------+-----+-------....----+--------------------+
    2 rows in set (0.00 sec)mysql> show table status like 't_iorikingdom';
    +---------------+--------+---------+----------.....----+-----------------------+
    | Name          | Engine | Version | Row_forma.....ons | Comment               |
    +---------------+--------+---------+----------.....----+-----------------------+
    | t_iorikingdom | InnoDB |      10 | Compact  .....    | comment for table汉字 |
    +---------------+--------+---------+----------.....----+-----------------------+
    1 row in set (0.00 sec)mysql>