更改MySQL存储过程“数据库排序规则"的名称 [英] Change MySQL stored procedure 'Database Collation' name

查看:319
本文介绍了更改MySQL存储过程“数据库排序规则"的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将数据库从本地计算机导入到服务器计算机.导入数据库时​​,系统默认将数据库的字符集值设置为拉丁".我已将数据库的字符集更改为"utf8".但是,数据库排序规则值的存储过程不会被修改.当前为"latin1_swedish_ci".如何将所有存储过程的数据库排序规则值从"latin1_swedish_ci"更改为"utf8_general_ci".

I have imported a DB from Local machine to server machine. While importing the Database, the character set values of the DB are set by system default to "Latin". I have changed the character set to "utf8" for the Database. But, the stored procedure of Database collation values are not modified. Currently it is "latin1_swedish_ci". How to change the Database collation values from "latin1_swedish_ci" to "utf8_general_ci" for all the stored procedures.

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;

谢谢.

推荐答案

创建过程和创建功能语法(添加了强调):

如果没有CHARACTER SETCOLLATE属性,则使用在例行创建时有效的数据库字符集和排序规则.为避免服务器使用数据库字符集和排序规则,请为字符数据参数提供显式的CHARACTER SETCOLLATE属性.

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存储过程“数据库排序规则"的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆