Home  >  Article  >  Database  >  How to change table name to uppercase in mysql

How to change table name to uppercase in mysql

藏色散人
藏色散人Original
2023-02-16 09:52:474014browse

Mysql method to change the table name to uppercase: 1. Open the command window; 2. Execute "SELECT concat('alter table ', TABLE_NAME , ' rename to ' , uppe(TABLE_NAME) ,' ;' ) FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'xxx';" command can change the table name to uppercase.

How to change table name to uppercase in mysql

The operating environment of this tutorial: Windows 10 system, MySQL version 5.7, Dell G3 computer.

mysql How to change the table name to uppercase?

mysql converts some table names into uppercase letters

1. Execute the following command (wen51 is the name of your database, you only need to change it here, no other changes are needed) to get the uppercase converted SQL statement of all table names in this database.

SELECT
 concat('alter table ', TABLE_NAME , ' rename to ' , upper(TABLE_NAME) ,' ;' ) 
FROM information_schema.TABLES 
WHERE  TABLE_SCHEMA = 'wen51';

How to change table name to uppercase in mysql

2. Copy the SQL statement of the table name that you need to change to uppercase from "Result 1" and execute it together.

How to change table name to uppercase in mysql

3. Pitfall Diary

alter table 原表名 rename to 新表名;

For example:

alter table sys_area rename to sys_area1;

There is no error in execution!
but! ! !

ALTER TABLE act_app_deployment RENAME TO UPPER('act_app_deployment');

will always report error 1064! ! !
UPPER function usage:
How to change table name to uppercase in mysql

Simply put: UPPER must be used after SELECT, it is only used to display results! ! !

Recommended learning: "MySQL Video Tutorial"

The above is the detailed content of How to change table name to uppercase in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn