1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
DROP TABLE IF EXISTS listing;
CREATE TABLE scores (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
name CHAR(30) NOT NULL,
score INT NOT NULL,
INDEX property (NAME, SCORE)
) DEFAULT CHARSET=UTF8;
SHOW CREATE TABLE scores;
Table Create Table
scores CREATE TABLE `scores` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` char(30) NOT NULL,
`score` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `property` (`name`,`score`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8mb3
INSERT INTO scores (name, score) VALUES("Taro Yamada", 29);
INSERT INTO scores (name, score) VALUES("Taro Yamada", -12);
INSERT INTO scores (name, score) VALUES("Jiro Yamada", 27);
INSERT INTO scores (name, score) VALUES("Taro Yamada", 10);
SELECT * FROM scores;
id name score
1 Taro Yamada 29
2 Taro Yamada -12
3 Jiro Yamada 27
4 Taro Yamada 10
REPLACE scores (id, name, score) VALUES (3, "Taro Yamada", 28);
SELECT * FROM scores;
id name score
1 Taro Yamada 29
2 Taro Yamada -12
3 Taro Yamada 28
4 Taro Yamada 10
SELECT * FROM scores WHERE name = "Taro Yamada" AND (score >= -12 AND score < 29);
id name score
2 Taro Yamada -12
4 Taro Yamada 10
3 Taro Yamada 28
DROP TABLE scores;
|