首页 > 编程知识 正文

mysql数据库中文列名(mysql列名为中文)

时间:2023-12-19 12:29:24 阅读:317680 作者:TYFM

本文目录一览:

现在的mysql支持中文表名和字段名吗

mysql支持中文表名和字段名,前提是设置好支持中文的字符集,例如 gb2312

例如:

-- 创建数据库时指定字符集 gb2312

create database test1

DEFAULT CHARACTER SET gb2312;

-- 转到刚创建的数据库

use test1;

--  创建中文数据表即中文字段

create table 学生表(

id int auto_increment primary key,

sid char(10) unique not null,

姓名 varchar(50) not null,

性别 bit,

生日 date);

数据库中怎么样使查询结果的列名为对应中文

1、创建测试表,create table test_student(stu_id number, class_id number);

2、插入测试数据,

insert into test_student values(1,1001);

insert into test_student values(2,1001);

insert into test_student values(3,1002);

insert into test_student values(4,1003);

insert into test_student values(5,1003);

insert into test_student values(6,1003);

commit;

3、查询数据表中内容,select * from test_student ;

4、将列名翻译为中文名进行展示,select stu_id as "学生编码", class_id as "课程编码" from test_student t;

MySQL中表的列名是不是不能用中文

最好不要使用中文,原因如下:

数据库的原始设计(以及所有的编程语言),都是基于英文,中文如果遇上乱码的问题,反正会很难处理。

打字老是切换中英文,这个速度上也会变慢了好多比如 select 学生名字 from 学生表格 where 学生年龄10; 中英文切换来切换去,实在是太麻烦了。

至于利,反正我看不到。除了说能一眼看到这个表名用上了中文,某些人会有莫名其秒的成就感,除此之后,我也想不出别的什么了。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。