Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of modifying Table and Field character set by MySQL

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the "MySQL modification table, field character set method", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "MySQL modification table, field character set method"!

Query all tables that are different from the database character set and generate a SQL that modifies the table character set:

Select b.tableroomnamereportb.columnaccounnamereportb.columnaccounnamereportb.collationationchangnamereparentific concat ('ALTER TABLE', b.tablefantnamereparentific 'MODIFY', b.columnlemnameparentific', b.DATARACTERTYPET'(', b.CHARACTERTERMAXIMUMCHARACTERCHARACTERTERMAXIMUMCHARACTERMAXIMUMLENGTHRENG')', CASE WHEN b.COLUMN_DEFAULT IS NULL THEN''ELSE CONCAT (' DEFAULT\'', b.COLUMNNDEFALT'\') END,' COMMENT\' ') executeSQL from information_schema.TABLES a journal information schema.COLUMNS b where b.character_set_name IS NOT NULL and a.TABLE_SCHEMA=b.TABLE_SCHEMA AND a.TABLE_NAME=b.TABLE_NAMEAND a.TABLECOLATION database name' database name'

Query all the fields in the database that are different from the table character set, and generate a modified SQL:

SELECT TABLE_NAME,CONCAT ('ALTER TABLE', TABLE_NAME,' DEFAULT CHARACTER SET', a. DEFAULTIX CHARACTERER SETRACTERSETIMEN 'COLLATE', a.DEFAULTING COLATIONAND name ') executeSQL FROM information_schema.SCHEMATA a _ The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report