DELETE ZSet


DELETE로 ZSet 데이터를 삭제

DELETE로 ZSet 데이터를 삭제합니다.

테스트 데이터 입력

Example

명령>zadd myzset1 10 value10 20 value20 30 value30 40 value40 50 value50
결과>5
명령>zadd myzset2 12.3 mem10 23.4 mem20 34.5 mem30 45.6 mem40 56.7 mem50
결과>5
명령>zadd myzset3 67.8 mem60 78.9 mem70 89.1 mem80 99.9 mem90 123.4 mem100
결과>5

Key로 삭제

DELETE FROM ZSET.MYSET1

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

Example

명령>select * from zset.myzset*;
결과>   0) key|score|value
  1) myzset1|10.0|value10
  2) myzset1|20.0|value20
  3) myzset1|30.0|value30
  4) myzset1|40.0|value40
  5) myzset1|50.0|value50
  6) myzset2|12.3|mem10
  7) myzset2|23.4|mem20
  8) myzset2|34.5|mem30
  9) myzset2|45.6|mem40
10) myzset2|56.7|mem50
11) myzset3|67.8|mem60
12) myzset3|78.9|mem70
13) myzset3|89.1|mem80
14) myzset3|99.9|mem90
15) myzset3|123.4|mem100
명령>delete from zset.myzset1;   opcode
결과> 1 keys deleted
명령>delete from zset.myzset*;  opcode
결과> 2 keys deleted

WHERE 조건

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

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

Example

명령> delete from zset.* where key > 'myzset2';   opcode
결과> 1 keys deleted
명령> delete from zset.* where value = 'mem10';   opcode
결과> 1 keys deleted
명령> delete from zset.* where value <= 'value20';   opcode
결과> 1 keys deleted
데이터 입력
명령> delete from zset.* where score = 10;   opcode
결과> 1 keys deleted
명령> delete from zset.* where score <= 70;   opcode
결과> 2 keys deleted

BETWEEN, NOT BETWEEN

Example

명령> delete from zset.* where key between 'myzset1' and 'myzset2';   opcode
결과> 2 keys deleted
명령> delete from zset.* where key not between 'myzset1' and 'myzset2';   opcode
결과> 1 keys deleted
데이터 입력
명령> delete from zset.* where value between 'mem20' and 'mem40';   opcode
결과> 1 keys deleted
명령> delete from zset.* where value not between 'mem20' and 'mem40';   opcode
결과> 2 keys deleted
데이터 입력
명령> delete from zset.* where score between 20 and 40;   between_5
결과> 2 keys deleted
명령> delete from zset.* where score not between 20 and 40;   between_6
결과> 1 keys deleted

IN, NOT IN

Example

명령> delete from zset.* where key in ('myzset1','myzset2');   opcode
결과> 2 keys deleted
명령> delete from zset.* where key not in ('myzset1','myzset2');   opcode
결과> 1 keys deleted
데이터 입력
명령> delete from zset.* where value in ('mem20','value30');   opcode
결과> 2 keys deleted
명령> delete from zset.* where value not in ('mem20');   opcode
결과> 1 keys deleted
데이터 입력
명령> delete from zset.* where score in (10, 12.3);   opcode
결과> 2 keys deleted
명령> delete from zset.* where score not in (10);   opcode
결과> 1 keys deleted

GLOB, NOT GLOB

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

Example

명령>delete from zset.* where value glob 'val*';   opcode
결과> 1 keys deleted
명령>delete from zset.* where value glob 'a*';   opcode
결과> 0 keys deleted
명령>delete from zset.* where value not glob 'a*';   opcode
결과> 2 keys deleted

LIKE, NOT LIKE

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

Example

명령>delete from zset.* where value like 'val%';   opcode
결과> 1 keys deleted
명령>delete from zset.* where value like 'A%';   opcode
결과> 0 keys deleted
명령>delete from zset.* where value not like 'A%';   opcode
결과> 2 keys deleted

OPCODE


delete from zset.myzset1;

delete from zset.myzset*;

delete from zset.* where key > 'myzset2';

delete from zset.* where value = 'mem10';

delete from zset.* where value <= 'value20';

delete from zset.* where score = 10;

delete from zset.* where score <= 70;

delete from zset.* where key between 'myzset1' and 'myzset2';

delete from zset.* where key not between 'myzset1' and 'myzset2';

delete from zset.* where value between 'mem20' and 'mem40';

delete from zset.* where value not between 'mem20' and 'mem40';

delete from zset.* where score between 20 and 40;

delete from zset.* where score not between 20 and 40;

delete from zset.* where key in ('myzset1','myzset2');

delete from zset.* where key not in ('myzset1','myzset2');

delete from zset.* where value in ('mem20','value30');

delete from zset.* where value not in ('mem20');

delete from zset.* where score in (10, 12.3);

delete from zset.* where score not in (10);

delete from zset.* where value glob 'val*';

delete from zset.* where value glob 'a*';

delete from zset.* where value not glob 'a*';

delete from zset.* where value like 'val%';

delete from zset.* where value like 'A%';

delete from zset.* where value not like 'A%';


<< Delete Set Delete ZSet Delete Hash >>

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

혹시 처음이세요?
레디스게이트에는 레디스에 대한 많은 정보가 있습니다.
레디스 소개, 명령어, SQL, 클라이언트, 서버, 센티널, 클러스터 등이 있습니다.
혹시 필요한 정보를 찾기 어려우시면 redisgate@gmail.com로 메일 주세요.
제가 찾아서 알려드리겠습니다.
 
close
IP를 기반으로 보여집니다.