21

I need to change table name from lowercase to uppercase but using this statement the table name can be changed but the names are in lowercase..

sql> rename table name to Name;

is there any way to convert table name to uppercase?

user2012
  • 251
  • 1
  • 6
  • 14

5 Answers5

27
  1. Add this line in the mysql server variables array in my.cnf:

    lower_case_table_names=2
    
  2. Restart your mysql server.

  3. Now you can create or alter tables in upper case, the server will accept your query.

Note that usually, on Linux systems, the main mysql configuration file can be found in /etc/my.cnf or /etc/mysql/my.cnf.

1stthomas
  • 731
  • 2
  • 15
  • 22
aleroot
  • 71,077
  • 30
  • 176
  • 213
7

Simple

sql> rename table name to tempName;
sql> rename table tempName to Name;

Without giving a tempName, MySQL does not recognize any change, ie when running sql> rename table name to Name; response is

Error Code: 1050. Table 'Name' already exists

SimPHP
  • 33
  • 1
  • 8
Alfred
  • 21,058
  • 61
  • 167
  • 249
5

This should give u what you are looking for...

ALTER TABLE oldtable RENAME TO NewTable;
peixe
  • 1,272
  • 3
  • 14
  • 31
5

If you use EasyPHP (Maybe it also works for WAMP/XAMP/LAMP?) this worked for me:

Open the following file in the EasyPHP installation folder:

\binaries\conf_files\my.ini

Just under the line where it is written:

[mysqld]

Write:

lower_case_table_names=2

So you'll have:

[mysqld]

lower_case_table_names=2

EasyPHP will notice the change in this file and restart, but you can always manualy restart to make sure.


You can test the variable using the command:

SHOW VARIABLES LIKE 'lower_case_table_names';

Or in phpMyAdmin go to: Home > Variables, and search for "lower case table names".

Community
  • 1
  • 1
Edu
  • 2,354
  • 5
  • 32
  • 36
0
  1. If you are using the XAMPP server then follow these steps:

    a. Open XAMPP and right click on Config button :
    b. Just under the line where it is written:

    [mysqld]

    Write

    lower_case_table_names=2

After this change restart the mySQL (Just Stop/Start)

enter image description here

Hardik Kalathiya
  • 2,221
  • 1
  • 18
  • 28