select * from information_schema.columns where table_schema = ‘db‘ #表所在数据库 and table_name = ‘tablename‘ ; #你要查的表
除了上述方法外还可以加上字段查询
使用mysql -uyourroot -pyourpassword 登录数据库
再使用use database;选中数据库
就可以在mysql查询表中包含有该字段中的行对应的注释信息
其中‘WH_BU_ORDER_RELATION‘为数据库表名称(可以查询其他表WH_BU_WORK_ORDER、WH_BU_EVENT)
其中‘order_relation_id‘数据库查询的字段名称(可以查询其他的字段apply_code、work_order_code等)
mysql> select* from information_schema.columns where table_name=‘WH_BU_ORDER_RELATION‘and COLUMN_NAME=‘order_relation_id‘;
+---------------+---------------+----------------------+-------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+-----------------+-------------+------------+-------+---------------------------------+-----------------------+
|TABLE_CATALOG | TABLE_SCHEMA |TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | COLUMN_DEFAULT |IS_NULLABLE | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH |NUMERIC_PRECISION | NUMERIC_SCALE | CHARACTER_SET_NAME | COLLATION_NAME | COLUMN_TYPE | COLUMN_KEY | EXTRA |PRIVILEGES |COLUMN_COMMENT |
+---------------+---------------+----------------------+-------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+-----------------+-------------+------------+-------+---------------------------------+-----------------------+
|NULL | whitehole | WH_BU_ORDER_RELATION | order_relation_id| 1 | NULL | NO | varchar | 36 | 108 | NULL | NULL | utf8 | utf8_general_ci | varchar(36) |PRI | | select,insert,update,references | 申请单关系主键 |
|NULL | whitehole_dev |WH_BU_ORDER_RELATION | order_relation_id | 1 | NULL | NO | varchar | 36 | 108 | NULL | NULL | utf8 | utf8_general_ci | varchar(36)| PRI | | select,insert,update,references | 申请单关系主键 |
+---------------+---------------+----------------------+-------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+-----------------+-------------+------------+-------+---------------------------------+-----------------------+
2rows in set (0.00 sec)
原文地址:http://blog.51cto.com/11298116/2130985