Since Mysql>=8.0 has supported collation in UTF8MB4.
But If the Column of type CHAR is an alphanumeric string, would it be better to custom collation in UTF8 or latin1 ?
I use Flask-Sqlalchemy
, and my project sets SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://root:@localhost:3306/testdb?charset=utf8mb4'
But After upgrade mysql to 8.0 , all tables are created with collation of UTF8MB4 .
eg:
class Topic(db.Model, CoModel):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(168))
content = db.Column(db.Text)
==> mysql
CREATE TABLE `topic` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(168) COLLATE utf8mb4_general_ci DEFAULT NULL,
`content` text COLLATE utf8mb4_general_ci ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
Should I custom name = db.Column(db.String(168, collation="utf8_general_ci"))
UTF8MB4 is good at support huge number of character encoding.
Should I configure utf8mb4 by default and use it everywhere ?