mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-03 11:52:54 +00:00
151 lines
4.3 KiB
Plaintext
151 lines
4.3 KiB
Plaintext
CREATE TABLE monitor (host STRING, ts TIMESTAMP, cpu DOUBLE DEFAULT 0, memory DOUBLE, TIME INDEX (ts), PRIMARY KEY(host));
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO monitor(ts, host, cpu, memory) VALUES
|
|
(1655276557000, 'host1', 66.6, 1024),
|
|
(1655276557000, 'host2', 66.6, 1024),
|
|
(1655276557000, 'host3', 66.6, 1024),
|
|
(1655276558000, 'host1', 77.7, 2048),
|
|
(1655276558000, 'host2', 77.7, 2048),
|
|
(1655276558000, 'host3', 77.7, 2048),
|
|
(1655276559000, 'host1', 88.8, 4096),
|
|
(1655276559000, 'host2', 88.8, 4096),
|
|
(1655276559000, 'host3', 88.8, 4096);
|
|
|
|
Affected Rows: 9
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
+---------------------+-------+------+--------+
|
|
| ts | host | cpu | memory |
|
|
+---------------------+-------+------+--------+
|
|
| 2022-06-15T07:02:37 | host1 | 66.6 | 1024.0 |
|
|
| 2022-06-15T07:02:37 | host2 | 66.6 | 1024.0 |
|
|
| 2022-06-15T07:02:37 | host3 | 66.6 | 1024.0 |
|
|
| 2022-06-15T07:02:38 | host1 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:38 | host2 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:38 | host3 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:39 | host1 | 88.8 | 4096.0 |
|
|
| 2022-06-15T07:02:39 | host2 | 88.8 | 4096.0 |
|
|
| 2022-06-15T07:02:39 | host3 | 88.8 | 4096.0 |
|
|
+---------------------+-------+------+--------+
|
|
|
|
DELETE FROM monitor WHERE host = 'host1' AND ts = 1655276557000::timestamp;
|
|
|
|
Affected Rows: 1
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
+---------------------+-------+------+--------+
|
|
| ts | host | cpu | memory |
|
|
+---------------------+-------+------+--------+
|
|
| 2022-06-15T07:02:37 | host2 | 66.6 | 1024.0 |
|
|
| 2022-06-15T07:02:37 | host3 | 66.6 | 1024.0 |
|
|
| 2022-06-15T07:02:38 | host1 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:38 | host2 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:38 | host3 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:39 | host1 | 88.8 | 4096.0 |
|
|
| 2022-06-15T07:02:39 | host2 | 88.8 | 4096.0 |
|
|
| 2022-06-15T07:02:39 | host3 | 88.8 | 4096.0 |
|
|
+---------------------+-------+------+--------+
|
|
|
|
DELETE FROM monitor WHERE host = 'host2';
|
|
|
|
Affected Rows: 3
|
|
|
|
ADMIN flush_table('monitor');
|
|
|
|
+------------------------------+
|
|
| ADMIN flush_table('monitor') |
|
|
+------------------------------+
|
|
| 0 |
|
|
+------------------------------+
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
+---------------------+-------+------+--------+
|
|
| ts | host | cpu | memory |
|
|
+---------------------+-------+------+--------+
|
|
| 2022-06-15T07:02:37 | host3 | 66.6 | 1024.0 |
|
|
| 2022-06-15T07:02:38 | host1 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:38 | host3 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:39 | host1 | 88.8 | 4096.0 |
|
|
| 2022-06-15T07:02:39 | host3 | 88.8 | 4096.0 |
|
|
+---------------------+-------+------+--------+
|
|
|
|
DELETE FROM monitor WHERE cpu = 66.6;
|
|
|
|
Affected Rows: 1
|
|
|
|
ADMIN flush_table('monitor');
|
|
|
|
+------------------------------+
|
|
| ADMIN flush_table('monitor') |
|
|
+------------------------------+
|
|
| 0 |
|
|
+------------------------------+
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor WHERE cpu = 66.6 ORDER BY ts;
|
|
|
|
++
|
|
++
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
+---------------------+-------+------+--------+
|
|
| ts | host | cpu | memory |
|
|
+---------------------+-------+------+--------+
|
|
| 2022-06-15T07:02:38 | host1 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:38 | host3 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:39 | host1 | 88.8 | 4096.0 |
|
|
| 2022-06-15T07:02:39 | host3 | 88.8 | 4096.0 |
|
|
+---------------------+-------+------+--------+
|
|
|
|
DELETE FROM monitor WHERE memory > 2048;
|
|
|
|
Affected Rows: 2
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor WHERE memory > 2048 ORDER BY ts;
|
|
|
|
++
|
|
++
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
+---------------------+-------+------+--------+
|
|
| ts | host | cpu | memory |
|
|
+---------------------+-------+------+--------+
|
|
| 2022-06-15T07:02:38 | host1 | 77.7 | 2048.0 |
|
|
| 2022-06-15T07:02:38 | host3 | 77.7 | 2048.0 |
|
|
+---------------------+-------+------+--------+
|
|
|
|
DROP TABLE monitor;
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE "MoNiToR" ("hOsT" STRING PRIMARY KEY, "tS" TIMESTAMP TIME INDEX, "cPu" DOUBLE DEFAULT 0);
|
|
|
|
Affected Rows: 0
|
|
|
|
DELETE FROM "MoNiToR" WHERE "hOsT" = 'host2';
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE "MoNiToR";
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE MoNiToR (hOsT STRING PRIMARY KEY, tS TIMESTAMP TIME INDEX, cPu DOUBLE DEFAULT 0);
|
|
|
|
Affected Rows: 0
|
|
|
|
DELETE FROM MoNiToR WHERE hOsT = 'host2';
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE MoNiToR;
|
|
|
|
Affected Rows: 0
|
|
|