diff --git a/doc/md/faq.md b/doc/md/faq.md index 428e0b078..3e02b4fbb 100644 --- a/doc/md/faq.md +++ b/doc/md/faq.md @@ -21,7 +21,8 @@ sidebar_label: FAQ [How to store Protobuf objects in a BLOB column?](#how-to-store-protobuf-objects-in-a-blob-column) [How to add `CHECK` constraints to table?](#how-to-add-check-constraints-to-table) [How to define a custom precision numeric field?](#how-to-define-a-custom-precision-numeric-field) -[How to configure two or more `DB` to separate read and write?](#how-to-configure-two-or-more-db-to-separate-read-and-write) +[How to configure two or more `DB` to separate read and write?](#how-to-configure-two-or-more-db-to-separate-read-and-write) +[How to change the character set and/or collation of a MySQL table?](#how-to-change-the-character-set-and-or-collation-of-a-mysql-table) ## Answers @@ -759,3 +760,22 @@ func (d *multiDriver) Close() error { } ``` +#### How to change the character set and/or collation of a MySQL table? + +By default for MySQL the character set `utf8mb4` is used and the collation of `utf8mb4_bin`. +However if you'd like to change the schema's character set and/or collation you need to use an annotation. + +Here's an example where we set the character set to `ascii` and the collation to `ascii_general_ci`. + +```go +// Annotations of the Entity. +func (Entity) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Annotation{ + Charset: "ascii", + Collation: "ascii_general_ci", + }, + } +} +``` +