更改MySQL存储过程“数据库排序规则”的名称

我已将数据库从本地计算机导入到服务器计算机.导入数据库时​​,系统默认将数据库的字符集值设置为“拉丁”.我已将数据库的字符集更改为“ 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.

转载注明原文:更改MySQL存储过程“数据库排序规则”的名称 - 代码日志