# Getting MySQL column comment metadata?

**URL:** <https://www.ruby-forum.com/t/getting-mysql-column-comment-metadata/112461>\
**Category:** Ruby\
**Created:** [August 19, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/getting-mysql-column-comment-metadata/112461 "2007-08-19T16:33:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [August 19, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/getting-mysql-column-comment-metadata/112461/1 "2007-08-19T16:33:35Z")

</div>

Hi All,

How do I go about getting the “Comments” metadata–the one I type via  
MySQL Administrator, for example–associated with a MySQL column?

I have been able to pull metadata from both ActiveRecord and DBI but  
cannot seem to find this added bit of info.

Thanks.  
Mario T. Lanza

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [August 19, 2007, 5:19pm UTC](https://www.ruby-forum.com/t/getting-mysql-column-comment-metadata/112461/2 "2007-08-19T17:19:33Z")

</div>

I’m not sure what you are asking, so I will take a guess…

If you want to access the metadata on all tables in db “MY\_DB” you can  
do something like…

SELECT table\_name, table\_type, engine FROM INFORMATION\_SCHEMA.tables  
WHERE table\_schema = ‘MY\_DB’ ORDER BY table\_type ASC, table\_name DESC;

Or you can just use “describe table\_name;” to get data on that specific  
table.

-mike

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [August 19, 2007, 7:11pm UTC](https://www.ruby-forum.com/t/getting-mysql-column-comment-metadata/112461/3 "2007-08-19T19:11:47Z")

</div>

On Sun, 19 Aug 2007 23:33:35 +0900, Mario T. Lanza wrote:

> Hi All,
> 
> How do I go about getting the “Comments” metadata–the one I type via  
> MySQL Administrator, for example–associated with a MySQL column?
> 
> I have been able to pull metadata from both ActiveRecord and DBI but  
> cannot seem to find this added bit of info.

This doesn’t appear to be implemented directily in MySQL’s C API.  
Certainly it’s not implemented in the direct MySQL Ruby API (see http://  
[MySQL/Ruby](http://www.tmtm.org/en/mysql/ruby/) and have a look at fetch\_fields and the  
Mysql::Field class). Since DBD::Myql uses fetch\_fields to determine what  
metadata is available, it’s not available in dbi. I don’t know about  
ActiveRecord, but I would expect the same thing.

The only way I know of to get this information is by running a “show  
full  
columns from TABLENAME” or using INFORMATION\_SCHEMA. (Well, there’s  
“show  
create table” too, but that requires parsing – why use that when you  
have “show full columns”)

–Ken

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [August 20, 2007, 1:00am UTC](https://www.ruby-forum.com/t/getting-mysql-column-comment-metadata/112461/4 "2007-08-20T01:00:55Z")

</div>

Thanks for the help. This is useful but I would like to use a library  
designed for providing this sort of information without regard to the  
underlying database. I attempted to clarify my original request, by  
posting:

[http://www.ruby-forum.com/topic/122032#544080](http://www.ruby-forum.com/topic/122032#544080)

Thanks again.

---

<div class="post-metadata">

**Author:** ![Mario\_TSL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Mario\_TSL](https://www.ruby-forum.com/u/Mario_TSL)\
**Post date:** [August 20, 2007, 3:54am UTC](https://www.ruby-forum.com/t/getting-mysql-column-comment-metadata/112461/5 "2007-08-20T03:54:19Z")

</div>

The column I was referring to appears in the attached screenshot. Far  
right. Notice “First name”.
