Getting MySQL column comment metadata?

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

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

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://
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

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

Thanks again.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs