----- Original Message ----- From: "Michael Satterwhite" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, September 25, 2004 12:29 PM Subject: Retrieving field characteristics
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > In order to make my field definitions more dynamic, I'd like to retrieve the > field length definition from the database. E.g. If a field is described as > varchar(5), I'd like to retrieve the "5" at runtime so as to limit the length > of data a user can present. > > Is there a way to do this using SQL? If so, how would I do this? > I don't think there's any way to do this with regular SQL at present. Most databases, like DB2, allow you to get this information quite easily via the catalog tables, which contain information about every column in every table (among many other things). But the MySQL catalog is not visible to users like you and me. A post I read the other day said that MySQL was planning to "expose its catalog" in Version 5; I assume that means that you will be able to query the catalog to get things like field lengths then. You can download Version 5 and run it but I gather that very little of the Version 5 functionality is present so far since they are still developing Version 4.1. You could try installing Version 5 and seeing if the catalog is accessible but I suspect it would be a wasted effort. There *is* one way to get the desired information TODAY (Version 4.0.x) but you're probably not going to like it. You *can* use Java to query the Database Metadata even in Version 4.0.x. That means you could use Java code to determine the lengths of columns (among other things). I've tried this and it works. Apparently, the MySQL JDBC driver can see the MySQL catalog to get this information. That means you would have to write Java code to get these field lengths. Interested? I didn't think so ;-) Rhino -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]