Re: dumb sql question
Posted in 1993
->From: Matthew Mashyna <mm5l+@andrew.cmu.edu>
->Subject: dumb sql question
->Date: Tue, 9 Mar 1993 14:00:19 -0500
->Reply-To: Matthew Mashyna <mm5l+@andrew.cmu.edu>
->Organization: Psychology, Carnegie Mellon, Pittsburgh, PA
->
->Is there a way to querry a database (whose name you do know) and get a
->list of its tables ? I'd also like to get a list of columns for a table
->(once I know its name)
->
->I'm trying to build an ad-hoc querry tool.
->
->Matt
->
-> Matt Mashyna
->--------------------------------------------------------------------------
-> email mashyna@cmu.edu * voice 412-268-2800 * fax: 412-268-2798
-> Manager of the Computing Facilities, CMU Psychology, Pittsburgh, PA 15213
->
Matt,
Ain't no such thing as a dumb question. If you learn from it, it's not dumb.
Just remember: "Ignorance can be cured, but stupid is forever."
Anyway, try these:
SELECT tabname FROM systables
WHERE NOT tabname MATCHES "sys*" { to not print the system catalog tables }
ORDER BY tabname;
SELECT tabname table_name, colname column_name, colno column_order
FROM systables t, syscolumns c
WHERE t.tabid = c.tabid
AND NOT tabname MATCHES "sys*" { to not print the system catalog tables }
ORDER BY tabname, colno
;
The column datatype is encoded numerically in syscolumns.coltype, so that is
a bit of a pain. One of the other netters (or I) can give you the trans-
lations, if you want them. Column size is encoded REALLY complexly in
syscolumns.collength. Some, but not all, of this info is in the "System
Catalogs" appendix, which carries different appendix letters in different docs.
If you need more info, be in touch.
Regards,
Alan
+------------------------------+---------------------------------------+
| R. Alan Popiel | Internet: alan@den.mmc.com |
| Martin Marietta, LSC | ( Please note: My opinions do not ) |
| P.O. Box 179, M/S 5422 | ( represent official Martin policy. ) |
| Denver, Colorado 80201-0179 | Voice: 303-977-9998 |
+------------------------------+---------------------------------------+