关于mysql的表名的大小写

Posted by 猪头小队长 | 程序设计 | Wednesday 6 May 2009 12:03

比较规矩的做法都是将所有的表名全部小写或者是全部大写,我比较喜欢全部小写,无论是在创建表的语句中还是在后面的CRUD语句中。然而,有时由于各种众所不知的原因,很难做到统一。于是该如何让mysql大小写不敏感呢?

在表名大小写敏感的情况下,表A和表a是不一样的,这样,如果在语句中还不分大小写的乱写,就会出现找不到表的错误,那此时的解决方案就是让它大小写不敏感:在my.conf中的mysqld栏目下加入一行:lower_case_table_names=1,然后重启mysql。

但是,如果以前,在大小写敏感的设置下,创建表时使用的是大写的表名,在执行完上面设置后会怎么样捏?这个表将不再会被访问到了。这下麻烦了:还得把上面设置改回去,然后将表名rename到小写,然后再加上上面的设置。

更多参考:http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word