更改 MySQL 存储过程 'Database Collation' 名称
Change MySQL stored procedure 'Database Collation' name
我已经将数据库从本地计算机导入到服务器计算机。导入数据库时,系统默认将数据库的字符集值设置为"Latin"。我已将数据库的字符集更改为“utf8
”。但是,数据库排序规则值的存储过程没有被修改。目前是“latin1_swedish_ci
”。如何将所有存储过程的数据库排序规则值从“latin1_swedish_ci
”更改为“utf8_general_ci
”。
SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = DB_Name;
USE DB_Name;
ALTER DATABASE DB_Name
DEFAULT CHARACTER SET = utf8
DEFAULT COLLATE=utf8_general_ci;
SET NAMES UTF8;
提前致谢。
如 CREATE PROCEDURE and CREATE FUNCTION Syntax 中所述(强调已添加):
If CHARACTER SET
and COLLATE
attributes are not present, the database character set and collation in effect at routine creation time are used. To avoid having the server use the database character set and collation, provide explicit CHARACTER SET
and COLLATE
attributes for character data parameters.
If you change the database default character set or collation, stored routines that use the database defaults must be dropped and recreated so that they use the new defaults.
我已经将数据库从本地计算机导入到服务器计算机。导入数据库时,系统默认将数据库的字符集值设置为"Latin"。我已将数据库的字符集更改为“utf8
”。但是,数据库排序规则值的存储过程没有被修改。目前是“latin1_swedish_ci
”。如何将所有存储过程的数据库排序规则值从“latin1_swedish_ci
”更改为“utf8_general_ci
”。
SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = DB_Name;
USE DB_Name;
ALTER DATABASE DB_Name
DEFAULT CHARACTER SET = utf8
DEFAULT COLLATE=utf8_general_ci;
SET NAMES UTF8;
提前致谢。
如 CREATE PROCEDURE and CREATE FUNCTION Syntax 中所述(强调已添加):
If
CHARACTER SET
andCOLLATE
attributes are not present, the database character set and collation in effect at routine creation time are used. To avoid having the server use the database character set and collation, provide explicitCHARACTER SET
andCOLLATE
attributes for character data parameters.If you change the database default character set or collation, stored routines that use the database defaults must be dropped and recreated so that they use the new defaults.