What query do I need to run in PHP to get the structure of a given table in the database and what query do I need to run to get a list of all the tables in the database.
+6
A:
To get a list of columns for a table, use the DESCRIBE SQL statement. The syntax is as follows:
DESCRIBE TableName
To get a list of tables on the database, use this SQL statement:
SHOW TABLES
MrValdez
2009-01-22 08:56:19
+3
A:
To get the CREATE syntax use
SHOW CREATE TABLE table_name;
Also take a look in the information_schema database. Lots of very useful information about your databases, tables, indexes, etc.
See: How to find all the tables in MySQL with specific column names in them?
Ken
2009-01-22 09:06:16