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;
Thanks in advance.
You can change the collation of any new objects that are created in a user database by using the COLLATE clause of the ALTER DATABASE statement. This statement does not change the collation of the columns in any existing user-defined tables. These can be changed by using the COLLATE clause of ALTER TABLE.
Alter Stored Procedure There is no statement in MySQL for modifying the parameters or the body of a stored procedure. To change parameters or the body, drop the stored procedure and create a new one. MySQL Workbench GUI allows users to alter a stored procedure where users can add parameters or change the code.
A collation name starts with the name of the character set with which it is associated, generally followed by one or more suffixes indicating other collation characteristics. For example, utf8mb4_0900_ai_ci and latin1_swedish_ci are collations for the utf8mb4 and latin1 character sets, respectively.
As documented under CREATE PROCEDURE and CREATE FUNCTION Syntax (emphasis added):
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With