Hello,
:-)))
>
>
>
> David A. Smith
Here are two clashing matters:
1. The management aspect
-------------------------
SQL engines used on sercer-side, in real production represent considerable material investment for the owners - due to the licence fees and / or the administrator / developer personnel salaries payed for maintaining the server, the database, freesource ( if the licence id free ).
Becouse of obvious security reasons only the db admin has access to the database metadata, and those admins in my country do sign up a nondisclosure agreement as part of their job contracts.
SQL engines used on client-side as desktop engines, mostly packaged in the same application installer, which will use them ( the Microsoft online installers do check the presence of the needed version of their SQL Server [Express] engine...for example when you downoad Visual Studio Express ).
In case of these desktop engines, it might be possible, that the software designer accepts interoperability with third-party software, and so guest users might have read permission to the metadata.
2. The technical aspect
--------------------------
Here is a similar thread for theoretical aspects:
http://arstechnica.com/civis/viewtopic.php?f=20&t=681067
As a practical application the xDB sample project present in the xBuilder demo here:
\xHB\Samples\Visual-xHarbour\xDB
has implemented a light-veight SQL interface by using SQLRDD.
xDB is my public domain code contribution, and the code referring table structures can be written in plain Clipper - the screen output is made in a VXH grid, but I think the code is simple enough to be read...
Ella
// displays metadata about schema tables
local cQuery
if cEngine == "MYSQL"
cQuery:="select left(table_name,32), "+;
"left(table_type,32), "+;
"convert(table_rows, char(32)), "+;
"convert(avg_row_length*table_rows, char(32)), "+;
"convert(create_time, char(32)), "+;
"convert(update_time, char(32)), "+;
"left(table_collation,32) "+;
"from information_schema.tables "+;
"where table_schema='"+cSchema+"' and table_name not like 'sr_mgmnt%' "+;
"order by table_name"
elseif cEngine == "FB"
cQuery:="select RDB$RELATION_NAME, "+;
"cast(RDB$FIELD_ID as CHAR(32)), "+;
"RDB$OWNER_NAME, "+;
"RDB$SECURITY_CLASS "+;
"from RDB$RELATIONS "+;
"where RDB$VIEW_BLR IS NULL and RDB$SYSTEM_FLAG=0 and RDB$RELATION_NAME not like 'SR_MGMNT%' "+;
"order by RDB$RELATION_NAME"
elseif cEngine == "MS"
cQuery:="select left(name, 32), "+;
"crdate, "+;
"type_txt = case type when 'U' then 'Table' else 'View' end, "+;
"ltrim(str(schema_ver,12)) "+;
"from sysobjects "+;
"where (type='U' or type='V') and name not like 'SR_MGMNT%' "+;
"order by name"
endif
::Cursor:=nCursorCalc
::Disable()
::Grid:Visible:=.f.
::Caption:="Schema Informations"
#ifdef XDB_SQLRDD
ASize( aCursor, 0)
oSQL:Exec( cQuery, .f., .t., @aCursor, , ,nMaxCursor )
#endif
if len(aCursor) < 1
::MessageBox("There are no tables in the current schema","",MB_OK)
::Enable()
::Cursor:=nCursorNormal
return Self
endif
if cEngine == "MYSQL" // update headers
::GridColumn1:Caption:="Table name"
::GridColumn2:Caption:="Table type"
::GridColumn3:Caption:="Rows"
::GridColumn4:Caption:="Table Length"
::GridColumn5:Caption:="Create time"
::GridColumn6:Caption:="Update time"
::GridColumn7:Caption:="Table collation"
elseif cEngine == "FB"
::GridColumn1:Caption:="Table name"
::GridColumn2:Caption:="Field ID"
::GridColumn3:Caption:="Owner name"
::GridColumn4:Caption:="Security class"
elseif cEngine == "MS"
::GridColumn1:Caption:="Table name"
::GridColumn2:Caption:="Table creation date"
::GridColumn3:Caption:="Table type"
::GridColumn4:Caption:="Schema version"
endif
::Caption:="Schema Informations - Tables"
::myInitGrid(Self) // refresh grid content
::Enable()
::Cursor:=nCursorNormal