如何使用插入语句将unicode字符插入mysql? [英] how do I insert unicode characters into mysql with an insert statement?

查看:116
本文介绍了如何使用插入语句将unicode字符插入mysql?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我直接在mysql客户端中执行此操作.我要执行以下操作:

I'm doing this directly in the mysql client. I want to do the following:

INSERT INTO MYTABLE VALUES(1,12,'\u5c40\u5c42');

因此它将插入两个unicode字符.我想尽可能不使用其他编程语言来执行此操作,我想将我的插入语句直接粘贴到mysql客户端中.

So it would insert the two unicode characters. I'd like to do this without using some other programming language if possible, I'd like to just paste my insert statements right into mysql client.

推荐答案

使用mysql控制台,我可以将您的unicode字符粘贴到insert命令中,然后mysql接受它.这是我使用您的数据进行的一次小测试:

Using the mysql console, I can just paste your unicode characters into an insert command and mysql accepts it. Here's a little test I did using your data:

CREATE TABLE xx (col1 varchar(20));
insert into xx values ('局层');
select * from xx;
+---------+
| col1    |
+---------+
| 局层   |
+---------+

我的数据库使用默认编码(latin1).

My db uses default encoding (latin1).

您是否尝试过仅将其粘贴?您会遇到什么错误?

Have you tried just pasting them in? What error, if any, do you get?

这篇关于如何使用插入语句将unicode字符插入mysql?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆