[Qt-interest] QtSql: fetching comments for tables and columns

Robert Hairgrove evorgriahr at hispeed.ch
Sun Apr 25 15:48:26 CEST 2010


Robert Hairgrove wrote:
> I couldn't find any methods in QSqlDatabase or QSqlDriver to do this. 
> However, most RDBMS which are conformant with SQL-92 will expose a 
> system table (or view) called "information_schema" which contains tables 
> called "tables" and "columns". At least in MySQL, each table contains a 
> field e.g. "table_comment" or "column_comment" which can be queried with 
> a normal SELECT statement -- assuming that the user has read permissions 
> on that schema.
> 
> How general is this in real life, though? Is "information_schema" called 
> by the same name in Oracle or MS SQL Server, for example? I think 
> exposing such table and column metadata would be a very handy feature to 
> have in Qt without resorting to platform-specific SQL queries of system 
> tables. To a large extent, it is already there (e.g. 
> QSqlDriver::record() and QSqlRecord::field() gives you almost 
> everything). But I am missing a property which returns the comments on 
> these objects, if available.

Well, it's actually SQL-2003 compliance, I suppose... But I found some 
VERY useful information here:

http://www.alberton.info

This, plus rummaging through the Qt source, should give me all I need to 
know.

IMHO, if there is an area in the QtSql module which could stand 
improvement, it is in wrapping the various ways of retrieving metadata 
from the different system tables in a platform-indiependent way. But I 
realize that it is far from trivial to cover all the bases (no pun 
intended), and I don't expect there to be a perfect solution for all RDBMS.



More information about the Qt-interest-old mailing list