有两个语句可以设置连接字符集,如下:
A
SET NAMES ‘charset_name‘ 相当于下面三句:
mysql> SET character_set_client = x;
mysql> SET character_set_results = x;
mysql> SET character_set_connection = x; #这个也设置了collation_connection的默认值x
B
SET CHARACTER SET charset_name 相当于下面三句:
mysql> SET character_set_client = x;
mysql> SET character_set_results = x;
mysql> SET collation_connection = @@collation_database;
character_set_results为NULL时,服务器对返回结果集不做任何转换
mysql> SET character_set_results = NULL;
因为字符集编码引起的问题在pg上报的错是:invalid byte sequence for encoding "UTF8",具体见参考