mysql字符集 排序規則

2022-05-05 17:06:09 字數 1597 閱讀 8780

select

schema_name '資料庫',

default_character_set_name '庫字符集',

default_collation_name '庫排序規則'

from

information_schema.schemata

where

(default_character_set_name != 'utf8mb4' or default_collation_name != 'utf8mb4_unicode_ci')

and schema_name not in ( 'sys', 'mysql', 'performance_schema', 'information_schema' );

select table_schema '資料庫',table_name '表',table_collation '表排序規則',table_rows '錶行數' from information_schema.tables where table_collation != 'utf8mb4_unicode_ci' and table_schema not in ('sys','mysql','performance_schema','information_schema');
如果是大表,那需要用到 gh-ost 來執行

select

schema_name '資料庫',

default_character_set_name '庫字元規則',

default_collation_name '庫排序規則',

concat( 'alter database ', schema_name, ' default character set utf8mb4 collate utf8mb4_unicode_ci;' ) '修正庫規則sql'

from

information_schema.schemata

where

(default_character_set_name != 'utf8mb4' or default_collation_name != 'utf8mb4_unicode_ci')

and schema_name not in ( 'sys', 'mysql', 'performance_schema', 'information_schema' );

select table_schema '資料庫',table_name '表',table_collation '排序規則',concat('alter table ',table_schema,'.', table_name, ' convert to character set utf8mb4 collate utf8mb4_unicode_ci;') '修正表規則sql' from information_schema.tables where table_collation != 'utf8mb4_unicode_ci' and table_schema not in ('sys','mysql','performance_schema','information_schema');

mysql字符集與排序規則

資料庫需要適應各種語言和字元就需要支援不同的字符集 character set 每種字符集也有各自的排序規則 collation 系統管理在安裝時定義乙個預設的字符集和排序規則。也可以在建立資料庫時對資料庫範圍,建表時對錶級別,甚至列級別設定字元和排序規則。檢視排序規則 字尾 cs或者 ci的意思是...

Mysql 字符集的排序規則

mysql字符集的排序規則,每種字符集都有其對應的排序規則 不同的排序規則造成的排序結果不同,排序規則可以是server級別的,database,table,column 字符集,character set,就是一套表示字元的符號和這些的符號的底層編碼 而校驗規則,則是在 字符集內用於比較字元的一套...

MySQL字符集與排序規則小結

utf8mb4說明 mysql在5.5.3之後增加了這個utf8mb4的編碼,mb4就是most bytes 4的意思,專門用來相容四位元組的unicode。好在utf8mb4是utf8的超集,除了將編碼改為utf8mb4外不需要做其他轉換。當然,為了節省空間,一般情況下使用utf8也就夠了。utf...