Question

My server default CHARSET is UTF-8 (set in my.cnf). I create tables like

CREATE TABLE t1
(
ID int(11) unsigned NOT NULL AUTO_INCREMENT,
Title varchar(255),
PRIMARY KEY(ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci KEY_BLOCK_SIZE=2

but some tables have only int columns. Is it beneficial to use latin charset for them? Or is it better to have all tables with UTF-8 charset for consistency?

CREATE TABLE t2
(
ID int(11) unsigned NOT NULL,
TagID int(11) unsigned NOT NULL,
PRIMARY KEY(ID,TagID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci KEY_BLOCK_SIZE=1

vs.

CREATE TABLE t2
(
ID int(11) unsigned NOT NULL,
TagID int(11) unsigned NOT NULL,
PRIMARY KEY(ID,TagID)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE latin1_swedish_ci KEY_BLOCK_SIZE=1
Was it helpful?

Solution

The character set and collation of a table affects the newly created columns in that table. It also affects char/text columns without a specified character set/collation.

So your int only tables don't have any specific difference because of character set, until you add a column that uses it.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top