snappymcsnap
snappymcsnap

Reputation: 2103

MySQL default character set

Does MySQL treat the default character setting in a cascading type of way?

For example, I'm looking at a script that generates the full db and it starts off with a statement like this:

CREATE SCHEMA IF NOT EXISTS `xyz` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;

so does that imply that all tables that are created as part of this db will use the UTF8 charset by default? And if I wanted to use a different charset for a given table I would simply have to define it on the CREATE TABLE statement? Is that accurate? Can I override on a specific field of a specific table too? thanks!

Upvotes: 2

Views: 504

Answers (1)

kitti
kitti

Reputation: 14814

Yes. If you set the charset and collation at the database (schema) level, it will apply to any newly created tables inside that database, unless those tables specify their own charset/collation in the CREATE TABLE statement.

And yes, you can also specify charset/collation on a per-field basis. Example from the MySQL manual:

CREATE TABLE t1
(
    col1 VARCHAR(5)
      CHARACTER SET latin1
      COLLATE latin1_german1_ci
);

Upvotes: 1

Related Questions