PDA

View Full Version : How to read INFORMATION_SCHEMA?


Kent Multer
06-16-06, 09:26 AM
Hi folks --

According to my MySQL documentation, a MySQL database has a "data dictionary," a database called INFORMATION SCHEMA that contains information about the other databases. This could be used to do operations like the Miva MvREVEALSTRUCTURE, that allow a script to open a database "blind," and find out at run-time what fields it contains. I got this example from a manual:

SELECT table_name, table_type
FROM information_schema.tables
WHERE table_schema = 'db5'
ORDER BY table_name;

I tried to execute this in phpMyAdmin, but coudn't get it to work. I'm a newbie at SQL; can anyone tell me how to get access to these tables?

Thanks --

Kent Multer
06-17-06, 06:08 AM
OK, I did some reading, and trial-and-error, and I have an answer to my own question. If anyone's interested ...

SQL has a number of "SHOW" queries that allow you to get information about the database. "SHOW COLUMNS" works similarly to the MvREVEALSTRUCTURE tag; and MvOPENVIEW works with these queries (at least, it works for SHOW COLUMNS). I just posted an example over at:

http://extranet.miva.com/forums/showthread.php?t=1851