Hello,
What precautions must be taken to use Chinese characters as MySQL table names?
Thanks in advance,
John
Hello,
What precautions must be taken to use Chinese characters as MySQL table names?
Thanks in advance,
John
You just need to be sure to properly escape table name anywhere using backqoutes. Besides this, it should be pretty safe to use any characters.
PS: And whenever non Chinese writing person will have to modify your code he will hate you for that.
Although you can probably do it safely within MySQL, whether it's right or wrong the reality is that you may end up having a hard time finding support for table names with unicode characters when using third party tools. That might include back-up solutions, development languages and APIs, etc. While it's nice to try to be global thinking, in this case I would probably stick with "standard" table names.
SQL supports delimited identifiers to allow table or column names to contain SQL keywords, whitespace, punctuation, other special characters, or international characters.
In MySQL, use back-quotes (or set the ANSI_QUOTES
SQL mode to use standard double-quotes).
Example:
mysql> create table `桌子` (id serial);
mysql> show create table `桌子`\G
--------------
show create table `桌子`
--------------
*************************** 1. row ***************************
Table: 桌子
Create Table: CREATE TABLE `桌子` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)