Re: how to query the structure of a database
Date: Wed, 30 Jan 2002 23:58:50 -0000
Message-ID: <7I%58.57075$ka7.9469174_at_news6-win.server.ntlworld.com>
"Massimo Fuccillo" <mfuccillonospam_at_tiscalinetnospam.it> wrote in message
news:D8958.18173$6e5.625842_at_twister2.libero.it...
> Hi all
>
> Is there a standard way (using SQL) to query the structure of a database?
>
> In other words:
> one or more query to obtain the names of the non system tables,
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
> one or more query, for each table, to obtain field names, field types,
field
> sizes
SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH FROM
INFORMATION_SCHEMA.COLUMNS
> one or more query for the constraints, indexes etc.
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
> independently from the database provider (Oracle, Db2, Sqlserver, etc)
Regards,
Greg Gaughan http://www.thinksql.co.uk
Received on Thu Jan 31 2002 - 00:58:50 CET