Search code examples
mysqltable-rename

can't rename mysql table


I'm trying to rename my table using this SQL. I'm using MySQL 5.1.41 on Windows XP.

USE 'bobby_tables';

    ALTER TABLE gc_acompte_fournisseur
      RENAME TO GC_Acompte_Fournisseur;

And the query claims to have executed correctly, but it lies! My table name is still all lower case!

What foul arcanery have I run afoul of that forbids me from capitalizing my tables?


Solution

  • It just how MySQL works on Windows:

    http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_lower_case_table_names

    • lower_case_table_names

    If set to 0, table names are stored as specified and comparisons are case sensitive. If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive. If set to 2, table names are stored as given but compared in lowercase. This option also applies to database names and table aliases. For additional information, see Section 8.2.2, “Identifier Case Sensitivity”.

    You should not set this variable to 0 if you are running MySQL on a system that has case-insensitive file names (such as Windows or Mac OS X). If you set this variable to 0 on such a system and access MyISAM tablenames using different lettercases, index corruption may result. On Windows the default value is 1. On Mac OS X, the default value is 2.

    If you are using InnoDB tables, you should set this variable to 1 on all platforms to force names to be converted to lowercase.

    (Emphasis mine)