Get database schema with one query?
The INFORMATION_SCHEMA.COLUMNS table has what you're asking for.
SELECT table_name, column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'YourDBName' ORDER BY table_name, ordinal_position
SELECT t.name AS tblName,SCHEMA_NAME(schema_id) AS [schemaName],c.name AS colNameFROM sys.tables AS tINNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_IDORDER BY tblName;
SELECT * FROM information_schema.tables tJOIN information_schema.columns c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_CATALOG=c.TABLE_CATALOG AND t.TABLE_SCHEMA=c.TABLE_SCHEMA
works for SQLSERVER 2005. The column names might be different for MySQL (I assume that's what you're using), but the concept is the same.