mysql中的转换类型数据类型_mysql数据类型转换

b5601b5c2b981916d32493a3c353015b.png

幕布斯6054654

CONVERT() provides a way to convert data between different character sets. The syntax is:CONVERT(expr USING transcoding_name)In MySQL, transcoding names are the same as the corresponding character set names.Examples:SELECT CONVERT(_latin1'Müller' USING utf8);INSERT INTO utf8table (utf8column)SELECT CONVERT(latin1field USING utf8) FROM latin1table;CONVERT(... USING ...) is implemented according to the standard SQL specification.You may also use CAST() to convert a string to a different character set. The syntax is:CAST(character_string AS character_data_type CHARACTER SET charset_name)Example:SELECT CAST(_latin1'test' AS CHAR CHARACTER SET utf8);If you use CAST() without specifying CHARACTER SET, the resulting character set and collation are defined by the character_set_connection and collation_connection system variables. If you use CAST() with CHARACTER SET X, the resulting character set and collation are X and the default collation of X.You may not use a COLLATE clause inside a CAST(), but you may use it outside. That is, CAST(... COLLATE ...) is illegal, but CAST(...) COLLATE ... is legal.Example:SELECT CAST(_latin1'test' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值