9

I read that it is best practise to have table names in Pascal Case (ThisIsMyTableName). Therefor I would like to change my tables in MySQL. But neither phpmyadmin, nore SQL Manager 2005 for MySQL will let me. The names stay to appear in lowercase, as if I didn't to a change at all.

Any suggestions to solve this problem?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Pascal Klein
  • 23,665
  • 24
  • 82
  • 119
  • 2
    I am assuming you are on Windows? – Pekka Dec 05 '10 at 19:49
  • Pekka: Is that relevant? – Gabe Dec 05 '10 at 19:50
  • 1
    @Gabe: yes, it is. Windows is not case-sensitive when it comes to MySQL table names, whereas other operating systems generally are. – Matchu Dec 05 '10 at 19:55
  • 4
    I disagree that this is best practice in MySQL, especially since case-sensitivity in MySQL table names is dependent on the underlying system. Just keep them lowercase and use_underscores. – Matchu Dec 05 '10 at 19:56

4 Answers4

8

The easiest way to take care of this is to add the following to your .ini file

lower_case_table_names=2

2 is the significance here for Windows. You can read more about it here Identifier Case Sensitivity

swisscheese
  • 1,765
  • 4
  • 23
  • 25
4

Use RENAME

example:

RENAME TABLE this_is_my_table_name TO ThisIsMyTableName;

details : http://dev.mysql.com/doc/refman/5.1/en/rename-table.html

ajreal
  • 46,720
  • 11
  • 89
  • 119
4

In MySQL, you can quote the table names everywhere to make them case preserving and sensitive.

`MyTableName`
wallyk
  • 56,922
  • 16
  • 83
  • 148
4

I advice against mixed case because of problems with case sensitivity. A fully tested solution on one platform where case doesn't matter may actually fail when deployed on a platform where case DOES matter. For that reason alone I suggest sticking with either all caps or all lower case. I use lower case because it is easier on the eye and make spelling errors easier to spot in fixed width fonts used in most editors.

Ronnis
  • 12,593
  • 2
  • 32
  • 52
  • I didnt know that the support of case sensivity in MySQL is dependet of the underlying Operating System. I guess I go for underscore! – Pascal Klein Dec 05 '10 at 22:51