MySQL 将表名更改为大写
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10928390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
change table name to upper case
提问by user2012
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?
有没有办法将表名转换为大写?
回答by aleroot
Add this line in the mysql server variables array in my.cnf:
lower_case_table_names=2
Restart your mysql server.
Now you can create or alter tables in upper case, the server will accept your query.
在 my.cnf 中的 mysql 服务器变量数组中添加这一行:
lower_case_table_names=2
重新启动您的 mysql 服务器。
现在您可以创建或更改大写表,服务器将接受您的查询。
Note that usually, on Linux systems, the main mysql configuration file can be found in /etc/my.cnf
or /etc/mysql/my.cnf
.
请注意,通常在 Linux 系统上,主要的 mysql 配置文件可以在/etc/my.cnf
或 中找到/etc/mysql/my.cnf
。
回答by peixe
This should give u what you are looking for...
这应该给你你正在寻找的东西......
ALTER TABLE oldtable RENAME TO NewTable;
回答by Edu
If you use EasyPHP (Maybe it also works for WAMP/XAMP/LAMP?) this worked for me:
如果您使用 EasyPHP(也许它也适用于 WAMP/XAMP/LAMP?),这对我有用:
Open the following file in the EasyPHP installation folder:
在 EasyPHP 安装文件夹中打开以下文件:
\binaries\conf_files\my.ini
\binaries\conf_files\my.ini
Just under the line where it is written:
就在它写的那一行下面:
[mysqld]
[mysqld]
Write:
写:
lower_case_table_names=2
lower_case_table_names=2
So you'll have:
所以你会有:
[mysqld]
lower_case_table_names=2
[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.
EasyPHP 会注意到此文件中的更改并重新启动,但您始终可以手动重新启动以确保。
You can test the variable using the command:
您可以使用以下命令测试变量:
SHOW VARIABLES LIKE 'lower_case_table_names';
显示变量如 'lower_case_table_names';
Or in phpMyAdmin go to: Home > Variables, and search for "lower case table names".
或者在 phpMyAdmin 中转到:主页 > 变量,然后搜索“小写表名”。
回答by blasteralfred Ψ
Simple
简单的
sql> rename table name to tempName;
sql> rename tempName name to TABLE;