gpt4 book ai didi

mysql - 更改 MySQL 存储过程 'Database Collation' 名称

转载 作者:可可西里 更新时间:2023-11-01 06:30:16 24 4
gpt4 key购买 nike

我已经将一个数据库从本地机器导入到服务器机器。导入数据库时​​,系统默认将数据库的字符集值设置为“拉丁文”。我已将数据库的字符集更改为“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 - 更改 MySQL 存储过程 'Database Collation' 名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34353072/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com