mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-08 22:32:55 +00:00
54 lines
1.5 KiB
SQL
54 lines
1.5 KiB
SQL
CREATE TABLE monitor (host STRING, ts TIMESTAMP, cpu DOUBLE DEFAULT 0, memory DOUBLE, TIME INDEX (ts), PRIMARY KEY(host));
|
|
|
|
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);
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
DELETE FROM monitor WHERE host = 'host1' AND ts = 1655276557000::timestamp;
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
DELETE FROM monitor WHERE host = 'host2';
|
|
|
|
ADMIN flush_table('monitor');
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
DELETE FROM monitor WHERE cpu = 66.6;
|
|
|
|
ADMIN flush_table('monitor');
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor WHERE cpu = 66.6 ORDER BY ts;
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
DELETE FROM monitor WHERE memory > 2048;
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor WHERE memory > 2048 ORDER BY ts;
|
|
|
|
SELECT ts, host, cpu, memory FROM monitor ORDER BY ts;
|
|
|
|
DROP TABLE monitor;
|
|
|
|
|
|
CREATE TABLE "MoNiToR" ("hOsT" STRING PRIMARY KEY, "tS" TIMESTAMP TIME INDEX, "cPu" DOUBLE DEFAULT 0);
|
|
|
|
DELETE FROM "MoNiToR" WHERE "hOsT" = 'host2';
|
|
|
|
DROP TABLE "MoNiToR";
|
|
|
|
CREATE TABLE MoNiToR (hOsT STRING PRIMARY KEY, tS TIMESTAMP TIME INDEX, cPu DOUBLE DEFAULT 0);
|
|
|
|
DELETE FROM MoNiToR WHERE hOsT = 'host2';
|
|
|
|
DROP TABLE MoNiToR;
|