MySQL5.7新特性試験
1379 ワード
CREATE TABLE `table_md5` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`param_value` char(15) NOT NULL,
`md5_value` varchar(35) GENERATED ALWAYS AS (md5(`param_value`)) VIRTUAL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
2.レコードの挿入
insert into table_md5(id,param_value) values(1,"123456");
insert into table_md5(id,param_value) values(2,"123456");
3.データの表示
+----+-------------+----------------------------------+
| id | param_value | md5_value |
+----+-------------+----------------------------------+
| 1 | 123456 | e10adc3949ba59abbe56e057f20f883e |
| 2 | 123456 | e10adc3949ba59abbe56e057f20f883e |
+----+-------------+----------------------------------+
4.データの更新
update table_md5 set param_value='123' where id=2;
5.データの表示
+----+-------------+----------------------------------+
| id | param_value | md5_value |
+----+-------------+----------------------------------+
| 1 | 123456 | e10adc3949ba59abbe56e057f20f883e |
| 2 | 123 | 202cb962ac59075b964b07152d234b70 |
+----+-------------+----------------------------------+
これでMySQLデータベースのパフォーマンスに大きな影響を及ぼすのではないでしょうか.の