views:

22

answers:

2

I need to have a list of tables in MySQL, that don`t have a column 'created' or 'modified', so I can add them if non existant. How can I achieve this?

Thanks in advance for any help / hint.

+1  A: 

Query INFORMATION_SCHEMA database for this.

http://dev.mysql.com/doc/refman/5.1/en/information-schema.html

FractalizeR
Thanks. The following query did the trick: SELECT c.table_name, COLUMN_NAMEFROM information_schema.`TABLES` t INNER JOIN information_schema.`COLUMNS` c ON t.table_name = c.table_namewhere column_name = 'created'OR column_name = 'modified' //for those interested. Thanks
tombom
@tombom Welcome :)
FractalizeR
A: 

You can do this from PHP. Connect to the database and browse the mysql table. It will have all table definitions, then run DESCRIBE on each table, that will get you the structure.

I can give you some code examples if you like

Yarek T
Thanks, but PHP is not an option.
tombom
// Nevermind, glad you found a solution
Yarek T