恰當的字符集,暢快的體驗!
00、Oracle字符集
Subsets and Supersets #子集與超集
Table A-11 Subset-Superset Pairs
| Subset(子集) |
Superset(超集) |
| AR8ADOS710 |
AR8ADOS710T |
| AR8ADOS720 |
AR8ADOS720T |
| AR8ADOS720T |
AR8ADOS720 |
| AR8APTEC715 |
AR8APTEC715T |
| AR8ARABICMACT |
AR8ARABICMAC |
| AR8ISO8859P6 |
AR8ASMO708PLUS |
| AR8ISO8859P6 |
AR8ASMO8X |
| AR8MUSSAD768 |
AR8MUSSAD768T |
| AR8MUSSAD768T |
AR8MUSSAD768 |
| AR8NAFITHA711 |
AR8NAFITHA711T |
| AR8NAFITHA721 |
AR8NAFITHA721T |
| AR8SAKHR707 |
AR8SAKHR707T |
| AR8SAKHR707T |
AR8SAKHR707 |
| BLT8CP921 |
BLT8ISO8859P13 |
| BLT8CP921 |
LT8MSWIN921 |
| D7DEC |
D7SIEMENS9780X |
| D7SIEMENS9780X |
D7DEC |
| DK7SIEMENS9780X |
N7SIEMENS9780X |
| I7DEC |
I7SIEMENS9780X |
| I7SIEMENS9780X |
IW8EBCDIC424 |
| IW8EBCDIC424 |
IW8EBCDIC1086 |
| KO16KSC5601 |
KO16MSWIN949 |
| LT8MSWIN921 |
BLT8ISO8859P13 |
| LT8MSWIN921 |
BLT8CP921 |
| N7SIEMENS9780X |
DK7SIEMENS9780X |
| US7ASCII |
|
| UTF8 |
AL32UTF8 |
| WE8DEC |
TR8DEC |
| WE8DEC |
WE8NCR4970 |
| WE8ISO8859P1 |
WE8MSWIN1252 |
| WE8ISO8859P9 |
TR8MSWIN1254 |
| WE8NCR4970 |
TR8DEC |
| WE8NCR4970 |
WE8DEC |
| WE8PC850 |
WE8PC858 |
注意:
直接修改oracle字符集,子集向超集轉變。是沒問題的。漢字在gbk下占2個字節、utf8下是3個字節
01、mysql字符集關系
11、查看mysq支持的字符集
show character set;

22、查看當前數據庫使用的字符集
show variables like '%character%';

參數解釋:
mysql和字符集有關的變量
character_set_client: 客戶端請求數據的字符集
character_set_connection:從客戶端接收到數據,然后傳輸的字符集
character_set_database: 默認數據庫的字符集,無論默認數據庫如何改變,都是這個字符集;如果沒有默認數據庫,那就使用 character_set_server指定的字符集,這個變量建議由系統自己管理,不要人為定義。
character_set_filesystem: 把os上文件名轉化成此字符集,即把 character_set_client轉換character_set_filesystem, 默認binary是不做任何轉換的
character_set_results: 結果集的字符集
character_set_server: 數據庫服務器的默認字符集
character_set_system: 這個值總是utf8,不需要設置,是為存儲系統元數據的字符集
修改mysql字符集的方法:
mysql> SET collation_connection = utf8_general_ci ;
mysql> SET collation_database = utf8_general_ci;
mysql> SET collation_server = utf8_general_ci ;
02、mysql客戶端請求字符集流轉過程
一個完整的用戶請求的字符集轉換流程是
1) mysql Server收到請求時將請求數據從character_set_client轉換為character_set_connection
2) 進行內部操作前將請求數據從character_set_connection轉換為內部操作字符集,步驟如下
A. 使用每個數據字段的CHARACTER SET設定值;
B. 若上述值不存在,則使用對應數據表的字符集設定值
C. 若上述值不存在,則使用對應數據庫的字符集設定值;
D. 若上述值不存在,則使用character_set_server設定值。
3) 最后將操作結果從內部操作字符集轉換為character_set_results

附上mysql5.6.x的my.cnf配置
[client] default-character-set=utf8 [mysql] auto-rehash default-character-set=utf8 [mysqld] user=mysql innodb_buffer_pool_size = 256M join_buffer_size = 128M sort_buffer_size = 20M read_rnd_buffer_size = 64M lower_case_table_names=1 max_allowed_packet=500M wait_timeout=200000 interactive_timeout=200000 datadir=/servyou_domain/mysql/data socket=/var/lib/mysql/mysql.sock init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake symbolic-links=0 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES log_bin_trust_function_creators=1 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/servyou_domain/mysql/data/mysqld.pid
