delete_set
DELETE Set
DELETE로 Set 데이터를 삭제
DELETE로 Set 데이터를 삭제합니다.
테스트 데이터 입력
Example
명령> | sadd myset1 mem10 mem20 mem30 mem40 mem50 |
결과> | 5 |
명령> | sadd myset2 10 20 30 40 50 |
결과> | 5 |
명령> | sadd myset3 45.6 12.3 34.5 23.4 56.7 |
결과> | 5 |
Key로 삭제
DELETE FROM SET.MYSET1
키 하나를 지정하거나 '*'를 사용해서 여러 개 키를 삭제할 수 있습니다.
Example
명령> | select * from set.myset* order by key, value; |
결과> |
0) key|value 1) myset1|mem10 2) myset1|mem20 3) myset1|mem30 4) myset1|mem40 5) myset1|mem50 6) myset2|10 7) myset2|20 8) myset2|30 9) myset2|40 10) myset2|50 11) myset3|12.3 12) myset3|23.4 13) myset3|34.5 14) myset3|45.6 15) myset3|56.7 |
명령> | delete from set.myset1; opcode |
결과> | 1 keys deleted |
명령> | delete from set.myset*; opcode |
결과> | 2 keys deleted |
WHERE 조건
비교: =, <, <=, >, >=, !=, <>
Where 조건으로 키를 삭제할 수 있습니다.
삭제 명령은 키가 지워지므로 필요한 키를 다시 넣고 시작하세요.
주의할 점은 where 조건에 value를 사용할 경우에도 키가 삭제됩니다.
Value만 삭제할 경우 레디스 원래 명령을 사용하세요.
Example
BETWEEN, NOT BETWEEN
Example
명령> | delete from set.* where key between 'myset1' and 'myset2'; opcode |
결과> | 2 keys deleted |
명령> | delete from set.* where key not between 'myset1' and 'myset2'; opcode |
결과> | 1 keys deleted |
데이터 입력 | |
명령> | delete from set.* where value between 20 and 40; opcode |
결과> | 2 keys deleted |
명령> | delete from set.* where value between 30 and 'value30'; opcode |
결과> | 1 keys deleted |
IN, NOT IN
Example
GLOB, NOT GLOB
*(별표), ?(물음표)
대소문자를 구분한다.
Example
LIKE, NOT LIKE
%(퍼센트), _(밑줄)
대소문자를 구분하지 않는다.
Example
OPCODE
delete from set.myset1;
delete from set.myset*;
delete from set.* where key > 'myset2';
delete from set.* where value = 'mem10';
delete from set.* where value <= 20;
delete from set.* where key between 'myset1' and 'myset2';
delete from set.* where key not between 'myset1' and 'myset2';
delete from set.* where value between 20 and 40;
delete from set.* where value between 30 and 'value30';
delete from set.* where key in ('myset1','myset2');
delete from set.* where value in ('mem10',34.5);
delete from set.* where value not in (30);
delete from set.* where value glob 'mem*';
delete from set.* where value not glob 'a*';
delete from set.* where value like 'mem%';
delete from set.* where value like 'A%';
delete from set.* where value not like 'A%';
<< Delete List | Delete Set | Delete ZSet >> |
---|
Email
답글이 올라오면 이메일로 알려드리겠습니다.