The only way I know to access anything resembling a "data dictionary" in
MySQL V4.* is via the Java MetaData interfaces. I use these occasionally in
my programs. In your case, you want the getColumnDisplaySize() method in the
ResultSetMetaData Interface. This code fragment demonstrates the technique:
----------------------------------------------------------------------------
------------------------
/* Determine the maximum length of the event_name column in the Events2
table. */
String query2 = "select event_name as event from SDAC.Events2";
ResultSetMetaData rsmd2 = null;
try {
stmt = conn01.createStatement();
rs = stmt.executeQuery(query2);
rsmd2 = rs.getMetaData();
String columnName = rsmd2.getColumnName(1);
String columnLabel = rsmd2.getColumnLabel(1);
String columnTypeName = rsmd2.getColumnTypeName(1);
int columnSize = rsmd2.getColumnDisplaySize(1);
System.out.println("The name of the event_name column is " +
columnName);
System.out.println("The label of the event_name column is " +
columnLabel);
System.out.println("The column type name of the event_name column is "
+ columnTypeName);
System.out.println("The size of the event_name column is " +
columnSize);
} catch(SQLException sql_excp) {
sql_excp.printStackTrace();
}
----------------------------------------------------------------------------
------------------------
This is the result of running that fragment:
----------------------------------------------------------------------------
------------------------
The name of the event_name column is event
The label of the event_name column is event
The column type name of the event_name column is VARCHAR
The size of the event_name column is 100
----------------------------------------------------------------------------
------------------------
(Note: If you omit the 'as event' from the query, both the column name and
the label name are 'event_name', not 'event. This may be a driver bug: I
would have though the original query should give 'event_name' as the column
name and 'event' as the label name.)
Aside from that, I think you have to wait until V5.* before you have any
command line SQL access to the MySQL catalog (or what you call a "data
dictionary").
Then again, there may be some third party tools that give you that
information which I don't know about.
Rhino
----- Original Message -----
From: "Ben Edwards" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, January 06, 2005 10:25 AM
Subject: Data Dictionary
> how do I access the Data Dictionary through SQL? What I want to do is
> loookup the length of a varchar for validation?
>
> Ben
> --
> Ben Edwards - Poole, UK, England
> WARNING:This email contained partisan views - dont ever accuse me of
> using the veneer of objectivity
> If you have a problem emailing me use
> http://www.gurtlush.org.uk/profiles.php?uid=4
> (email address this email is sent from may be defunct)
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]