使用SQL語句修改Mysql資料庫字元集的方法 修改庫: alter database [$database] character set [$character_set] collate [$collation_name] 註:[$database]為資料庫的庫名。[$character_set] ...
使用SQL語句修改Mysql資料庫字元集的方法 修改庫:
alter database [$database] character set [$character_set] collate [$collation_name]
註:
[$database]為資料庫的庫名。
[$character_set]為字元集名稱。
[$collation_name]為排序規則名稱。
eg:
alter database dbsdq character set utf8mb4 collate utf8mb4_unicode_ci;
alter table [$table] convert to character set [$character_set] collate [$collation_name]
註:
[$table]為表名。
eg:
alter table tt2 convert to character set utf8mb4 collate utf8mb4_unicode_ci;
修改一列:
alter table [$table] modify [$column_name] [$field_type] character set [$character_set] collate [$collation_name]
註:
[$column_name]為欄位名。
[$field_type]為欄位類型。
eg:
alter table tt2 modify c2 varchar(10) character set utf8mb4 collate utf8mb4_unicode_ci;