你好,我在做一个人员管理系统,想为每一个单位创建一个库,代码已经写完了,突然发现数据库名,数据表名不支持 汉字,和全数字 错误代码如下:(我在终端里的命令)mysql> create database 北京大学; ERROR 1064 (42000): You have an error in your SQL syntax; \ check the manual that corresponds to your MySQL server version for the right syntax to use near '�京大学' at line 1mysql> create database ‘北京大学’; ERROR 1064 (42000): You have an error in your SQL syntax; \ check the manual that corresponds to your MySQL server version for the right syntax to use near '北京大学’' at line 1
字符集问题 set names gbk 再输入SQL命令 show variables like 'char%';
可以用中文,用 set names 'gbk' 或者 set names 'gb2312'; 设置字符集后,即可使用中文对象名。 但不推荐用中文做表名或字段名。
汉字,和全数字
错误代码如下:(我在终端里的命令)mysql> create database 北京大学;
ERROR 1064 (42000): You have an error in your SQL syntax; \
check the manual that corresponds to your MySQL server version for the right syntax to use near '�京大学' at line 1mysql> create database ‘北京大学’;
ERROR 1064 (42000): You have an error in your SQL syntax; \
check the manual that corresponds to your MySQL server version for the right syntax to use near '北京大学’' at line 1
set names gbk
再输入SQL命令
show variables like 'char%';
但不推荐用中文做表名或字段名。