DELETE Stream


DELETE로 Stream 키를 삭제

DELETE로 Stream 키를 삭제합니다.

테스트 데이터 입력

Example

명령>xadd sensor1 * temp 10 humid 20 pres 30 vib 40 flag AA1
명령>xadd sensor2 * temp 11 humid 25 pres 28 vib 50 flag AA2
명령>xadd sensor3 * temp 12 humid 30 pres 26 vib 60 flag AA3
명령>xadd sensor4 * temp 13 humid 35 pres 24 vib 20 flag BB1
명령>xadd sensor5 * temp 14 humid 40 pres 22 vib 30 flag BB2

Key로 삭제

DELETE FROM STREAM.SENSOR1

키 하나를 지정하거나 '*'를 사용해서 여러 개 키를 삭제할 수 있습니다.

Example

명령>select * from stream.*;
결과> 0) key|id|temp|humid|pres|vib|flag
1) sensor1|1623474437867-0|10|20|30|40|AA1
2) sensor2|1623474570594-0|11|25|28|50|AA2
3) sensor3|1623474576131-0|12|30|26|60|AA3
4) sensor4|1623474580851-0|13|35|24|20|BB1
5) sensor5|1623474585754-0|14|40|22|30|BB2
명령>delete from stream.sensor1;   opcode
결과> 1 keys deleted
명령>delete from stream.sensor*;   opcode
결과> 4 keys deleted

WHERE 조건

비교: =, <, <=, >, >=, !=, <>

Where 조건으로 키를 삭제할 수 있습니다.
삭제 명령은 키가 지워지므로 필요한 키를 다시 넣고 시작하세요.
주의할 점은 where 조건에 field를 사용할 경우에도 키가 삭제됩니다.
field만 삭제할 경우 레디스 원래 명령을 사용하세요.

Example

명령> delete from stream.* where key > 'sensor4';   opcode
결과> 1 keys deleted
명령> delete from stream.* where temp = 10;   opcode
결과> 1 keys deleted
명령> delete from stream.* where humid <= 30;   opcode
결과> 2 keys deleted
명령> delete from stream.* where flag = 'BB1';   opcode
결과> 1 keys deleted

BETWEEN, NOT BETWEEN

Example

명령> delete from stream.* where key between 'sensor1' and 'sensor2';   opcode
결과> 2 keys deleted
명령> delete from stream.* where key not between 'sensor1' and 'sensor2';   opcode
결과> 3 keys deleted
데이터 입력
명령> delete from stream.* where humid between 25 and 30;   opcode
결과> 2 keys deleted
명령> delete from stream.* where humid not between 25 and 30;   opcode
결과> 3 keys deleted

IN, NOT IN

Example

명령> delete from stream.* where key in ('sensor1','sensor2');   opcode
결과> 2 keys deleted
명령> delete from stream.* where key not in ('sensor1','sensor2');   opcode
결과> 3 keys deleted
데이터 입력
명령> delete from stream.* where humid in (25,30);   opcode
결과> 2 keys deleted
명령> delete from stream.* where humid not in (25,30);   opcode
결과> 3 keys deleted

GLOB, NOT GLOB

*(별표), ?(물음표)
대소문자를 구분한다.

Example

명령> delete from stream.* where flag glob 'AA*';   opcode
결과> 3 keys deleted
명령> delete from stream.* where flag glob 'CC*';   opcode
결과> 0 keys deleted
명령> delete from stream.* where flag not glob 'CC*';   opcode
결과> 2 keys deleted

LIKE, NOT LIKE

%(퍼센트), _(밑줄)
대소문자를 구분하지 않는다.

Example

명령>delete from stream.* where flag like 'AA%';   opcode
결과> 3 keys deleted
명령>delete from stream.* where flag like 'CC%';   opcode
결과> 0 keys deleted
명령>delete from stream.* where flag not like 'CC%';   opcode
결과> 2 keys deleted

테스트 데이터 입력

Example

명령>xadd sensor_1 * temp 10 humid 20 pres 30 vib 40
명령>xadd sensor_1 * temp 11 humid 25 pres 28 vib 50
명령>xadd sensor_1 * temp 12 humid 30 pres 26 vib 60
명령>xadd sensor_1 * temp 13 humid 35 pres 24 vib 20
명령>xadd sensor_1 * temp 14 humid 40 pres 22 vib 30
명령>xadd sensor_2 * temp 124.7 humid 46.8 pres 150.4 flag AA1
명령>xadd sensor_2 * temp 123.4 humid 50.4 pres 148.6 flag AA2
명령>xadd sensor_2 * temp 119.8 humid 48.1 pres 149.2 flag BB1
명령>xadd sensor_2 * temp 128.1 humid 51.2 flag BB2
명령>xadd sensor_2 * temp 117.4 humid 46.7 flag BB3
명령>xadd sensor_3 * temp 10
명령>xadd sensor_3 * temp 50
명령>xadd sensor_3 * temp 30
명령>xadd sensor_3 * temp 20
명령>xadd sensor_3 * temp 40
명령>xadd mys1 * temp 10
명령>xadd mys1 * temp 50
명령>xadd mys1 * temp 30

비교: =, <, <=, >, >=, !=, <>

Example

명령> delete from stream.* where temp = 10;   opcode
결과> 3 keys deleted
명령> delete from stream.* where temp > 30;   opcode
결과> 1 keys deleted

BETWEEN, NOT BETWEEN

Example

명령> delete from stream.* where temp between 25 and 30;   opcode
결과> 2 keys deleted
명령> delete from stream.* where temp not between 25 and 30;   opcode
결과> 2 keys deleted

IN, NOT IN

Example

명령> delete from stream.* where temp in (25,30);   opcode
결과> 2 keys deleted
명령> delete from stream.* where temp not in (25,30);   opcode
결과> 2 keys deleted

GLOB

*(별표), ?(물음표)
대소문자를 구분한다.

Example

명령> delete from stream.* where flag glob 'AA*';   opcode
결과> 1 keys deleted

LIKE

%(퍼센트), _(밑줄)
대소문자를 구분하지 않는다.

Example

명령>delete from stream.* where flag like 'AA%';   opcode
결과> 1 keys deleted

OPCODE


delete from stream.sensor1;

delete from stream.sensor*;

delete from stream.* where key > 'sensor4';

delete from stream.* where temp = 10;

delete from stream.* where humid <= 30;

delete from stream.* where flag = 'BB1';

delete from stream.* where key between 'sensor1' and 'sensor2';

delete from stream.* where key not between 'sensor1' and 'sensor2';

delete from stream.* where humid between 25 and 30;

delete from stream.* where humid not between 25 and 30;

delete from stream.* where key in ('sensor1','sensor2');

delete from stream.* where key not in ('sensor1','sensor2');

delete from stream.* where humid in (25,30);

delete from stream.* where humid not in (25,30);

delete from stream.* where flag glob 'AA*';

delete from stream.* where flag glob 'CC*';

delete from stream.* where flag not glob 'CC*';

delete from stream.* where flag like 'AA%';

delete from stream.* where flag like 'CC%';

delete from stream.* where flag not like 'CC%';

delete from stream.* where temp = 10;

delete from stream.* where temp > 30;

delete from stream.* where temp between 25 and 30;

delete from stream.* where temp not between 25 and 30;

delete from stream.* where temp in (25,30);

delete from stream.* where temp not in (25,30);

delete from stream.* where flag glob 'AA*';

delete from stream.* where flag like 'AA%';


<< Select Hash Select Stream Select Subquery >>

Email 返事がかかってなれば、メールでお知らせします。