Setting character sets on tables and fields

suggest change

You can set a character set both per table, as well as per individual field using the CHARACTER SET and CHARSET statements:

CREATE TABLE Address (
    `AddressID`   INTEGER NOT NULL PRIMARY KEY,
    `Street`      VARCHAR(80) CHARACTER SET ASCII,
    `City`        VARCHAR(80),
    `Country`     VARCHAR(80) DEFAULT "United States",
    `Active`      BOOLEAN DEFAULT 1,
) Engine=InnoDB default charset=UTF8;

City and Country will use UTF8, as we set that as the default character set for the table. Street on the other hand will use ASCII, as we’ve specifically told it to do so.

Setting the right character set is highly dependent on your dataset, but can also highly improve portability between systems working with your data.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents