DROP TABLE IF EXISTS diaries;
CREATE TABLE diaries (
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
title VARCHAR(100) NOT NULL,
content TEXT NOT NULL,
PRIMARY KEY (date, title)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='ENGINE "MyISAM"';
SHOW CREATE TABLE diaries;
Table	Create Table
diaries	CREATE TABLE `diaries` (
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `title` varchar(100) NOT NULL,
  `content` text NOT NULL,
  PRIMARY KEY (`date`,`title`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='ENGINE "MyISAM"'
INSERT INTO diaries (date, title, content)
VALUES ("2012-03-04", "cloudy day", "Today is cloudy day...");
INSERT INTO diaries (date, title, content)
VALUES ("2012-03-04", "shopping", "I buy a new shirt.");
INSERT INTO diaries (date, title, content)
VALUES ("2012-03-05", "rainy day", "Today is rainy day...");
SELECT * FROM diaries;
date	title	content
2012-03-04 00:00:00	cloudy day	Today is cloudy day...
2012-03-04 00:00:00	shopping	I buy a new shirt.
2012-03-05 00:00:00	rainy day	Today is rainy day...
INSERT INTO diaries (date, title, content)
VALUES ("2012-03-04", "shopping", "I buy new shoes.")
ON DUPLICATE KEY UPDATE date = "2012-03-03",
content = "I buy a new hat.";
SELECT * FROM diaries;
date	title	content
2012-03-04 00:00:00	cloudy day	Today is cloudy day...
2012-03-03 00:00:00	shopping	I buy a new hat.
2012-03-05 00:00:00	rainy day	Today is rainy day...
DROP TABLE diaries;
