[wp-hackers] hyphens to differentiate database names for WP in mysql

Otto otto at ottodestruct.com
Mon May 20 19:30:15 UTC 2013


On Mon, May 20, 2013 at 1:40 PM, Cameron Hurd <me at cameronhurd.com> wrote:
> But, there is that table_prefix variable to facilitate multiple wp installs in one db. Any plugin running queries is alreading prepending this to table names when running queries. According to the ol' codex, it says only numbers, letters and underscores - http://codex.wordpress.org/Editing_wp-config.php#table_prefix
>
> As for the name of the actual db itself, I don't see why hyphens would be bad practice. I think it's just preference.
>
> Any other thoughts?

http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

Certain objects within MySQL, including database, table, index,
column, alias, view, stored procedure, partition, and other object
names are known as identifiers. This section describes the permissible
syntax for identifiers in MySQL.
...
An identifier may be quoted or unquoted. If an identifier contains
special characters or is a reserved word, you must quote it whenever
you refer to it.
...
Identifiers are converted to Unicode internally. They may contain
these characters:

Permitted characters in unquoted identifiers:
ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)
Extended: U+0080 .. U+FFFF

Permitted characters in quoted identifiers include the full Unicode
Basic Multilingual Plane (BMP), except U+0000:
ASCII: U+0001 .. U+007F
Extended: U+0080 .. U+FFFF


Note that "hyphen" is not in the list of permitted characters for
unquoted identifiers. WordPress does not use quoted identifiers
everywhere (although it probably should, I suspect), so hyphens are
currently a no-no.

Use underscores instead. Safer.

-Otto


More information about the wp-hackers mailing list