本文目錄一覽:
現在的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; 中英文切換來切換去,實在是太麻煩了。
至於利,反正我看不到。除了說能一眼看到這個表名用上了中文,某些人會有莫名其秒的成就感,除此之後,我也想不出別的什麼了。
原創文章,作者:YVRSZ,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/325107.html