tags:

views:

50

answers:

1

I have to check for the existence of several tables from a shell script, without accessing the MySQL daemon. Is the presence of .frm files reliable to determine if the tables exist or not? Here's what I have been doing, but it doesn't seem to work all the time (there may be an error in another part of the system):

for table in $TABLES; do
    if [ -f /data/mysql/${database}/${table}.frm ]; then
        ...
        ...
    fi
done

Is this reliable? If not, is there another way to achieve this?

+2  A: 

Yes, there will always be a .frm file for each table.

Jeremy Stein
The question is, will there always be a table for each `.frm` file?
Thomas
@Thomas: The answer to that is yes, unless you have corrupted tables or just copied the .frm files around for whatever reason. .frm files are the only constant between MySQL's various database engines.
R. Bemrose
Thank you. @Thomas: good question. @R. Bemrose: excellent answers.
Tom