Ron Savage wrote:

HI Folks

Recent versions of DBI and/or DBD::mysql return backticks around the names of tables.


That has to do with how the MySQL daemon is started. If it is started with the --ansi flag, either backticks or double quotes may be used for quoted identifier delimiters. Otherwise backticks are used exculusively. Backticks are the MySQL default. Different instances of MySQL will use different delimiters depending on how they are started, not on how recent the MySQL version is or anything about DBI or DBD::mysql, AFAIK. If you remove the backticks from a table name that needs to be delimited (e.g. one that's the same as SQL reserved word), you will be making the table inaccessible to MySQL by removing them.

For example, this will produce an error on the second SELECT (but not the first SELECT) because table is not a valid table name but `table` is.

my $table  = q/`table`/;
my $table2 = q/table/;
$dbh->do(qq/DROP TABLE IF EXISTS $table/);
$dbh->do(qq/CREATE TABLE $table (id INTEGER)/);
$dbh->do(qq/INSERT INTO $table VALUES(7)/);
print $dbh->selectall_arrayref(qq/SELECT * FROM $table/)->[0]->[0];
print $dbh->selectall_arrayref(qq/SELECT * FROM $table2/)->[0]->[0];

--
Jeff




Reply via email to