Community journal

The latest from the MySQL community

Ideas, releases, practical guides, and perspectives from the people building with MySQL.

Follow the feed
Showing entries 1 to 1 of 1 « Previous | Next »
Displaying posts with tag: utf8_bin (reset)
Generated Columnの活用例

MySQL5.7から追加されたGenerated Column(生成列)を使って、色々と便利な事が出来るようになりました。
先日、Generated Columnを利用してMySQLの照合順を説明したのでその時に利用した生成列をサンプル兼メモです。

Default: utf8_general_ci or utf8mb4_general_ciの場合
英語の大文字、小文字は同じ文字として扱う。


root@localhost [CONFIRM]> show create table T_Character\G
*************************** 1. row ***************************
       Table: T_Character
Create Table: CREATE TABLE `T_Character` (
  `pid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `string1` char(1) DEFAULT NULL,
  `string2` char(1) DEFAULT NULL,
  `string1_w_string` char(4) GENERATED ALWAYS AS (hex(weight_string(`string1`))) VIRTUAL,
  `string2_w_string` char(4) GENERATED ALWAYS AS (hex(weight_string(`string2`))) VIRTUAL,
  `compare` char(1) GENERATED ALWAYS AS …
[さらに読む]