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

Robert Hairgrove evorgriahr at hispeed.ch
Sat Apr 24 13:36:47 CEST 2010


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.



More information about the Qt-interest-old mailing list