DELETE Hash


DELETE로 Hash 키를 삭제

DELETE로 Hash 키를 삭제합니다.

테스트 데이터 입력

Example

명령>hset myname1 name kim age 25 birthday 1995-01-01 city Seoul
결과>4
명령>hset myname2 name kang age 30 birthday 1990-01-01 city Daejeon
결과>4
명령>hset myname3 name park age 20 birthday 2000-01-01 city Seoul hobby ski,bike
결과>5
명령>hset myname4 name choe age 30 birthday 1990-01-01 city Daejeon
결과>4
명령>hset myname5 name lee age 35 birthday 1985-01-01 city Busan
결과>4

Key로 삭제

DELETE FROM HASH.MYNAME1

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

Example

명령>select * from hash.*;
결과> 0) key|name|age|birthday|city|hobby
1) myname1|kim|25|1995-01-01|Seoul|
2) myname2|kang|30|1990-01-01|Daejeon|
3) myname3|park|20|2000-01-01|Seoul|ski,bike
4) myname4|choe|30|1990-01-01|Daejeon|
5) myname5|lee|35|1985-01-01|Busan|
명령>delete from hash.myname1;   opcode
결과> 1 keys deleted
명령>delete from hash.myname*;   opcode
결과> 4 keys deleted

WHERE 조건

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

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

Example

명령> delete from hash.* where key > 'myname4';   opcode
결과> 1 keys deleted
명령> delete from hash.* where name = 'kim';   opcode
결과> 1 keys deleted
명령> delete from hash.* where age <= 30;   opcode
결과> 3 keys deleted
데이터 입력
명령> delete from hash.* where hobby is null;   opcode
결과> 4 keys deleted

BETWEEN, NOT BETWEEN

Example

명령> delete from hash.* where key between 'myname1' and 'myname2';   opcode
결과> 2 keys deleted
명령> delete from hash.* where key not between 'myname1' and 'myname2';   opcode
결과> 3 keys deleted
데이터 입력
명령> delete from hash.* where age between 25 and 30;   opcode
결과> 3 keys deleted
명령> delete from hash.* where age not between 25 and 30;   opcode
결과> 2 keys deleted

IN, NOT IN

Example

명령> delete from hash.* where key in ('myname1','myname2');   opcode
결과> 2 keys deleted
명령> delete from hash.* where key not in ('myname1','myname2');   opcode
결과> 3 keys deleted
데이터 입력
명령> delete from hash.* where city in ('Seoul','Daejeon');   opcode
결과> 4 keys deleted
명령> delete from hash.* where city not in ('Seoul','Daejeon');   opcode
결과> 1 keys deleted

GLOB, NOT GLOB

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

Example

명령> delete from hash.* where city glob 'Seo*';   opcode
결과> 2 keys deleted
명령> delete from hash.* where city glob 'A*';   opcode
결과> 0 keys deleted
명령> delete from hash.* where city not glob 'A*';   opcode
결과> 3 keys deleted

LIKE, NOT LIKE

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

Example

명령>delete from hash.* where birthday like '19%';   opcode
결과> 4 keys deleted
명령>delete from hash.* where birthday like '19%';   opcode
결과> 0 keys deleted
명령>delete from hash.* where birthday not like '19%';   opcode
결과> 1 keys deleted

OPCODE


delete from hash.myname1;

delete from hash.myname*;

delete from hash.* where key > 'myname4';

delete from hash.* where name = 'kim';

delete from hash.* where age <= 30;

delete from hash.* where hobby is null;

delete from hash.* where key between 'myname1' and 'myname2';

delete from hash.* where key not between 'myname1' and 'myname2';

delete from hash.* where age between 25 and 30;

delete from hash.* where age not between 25 and 30;

delete from hash.* where key in ('myname1','myname2');

delete from hash.* where key not in ('myname1','myname2');

delete from hash.* where city in ('Seoul','Daejeon');

delete from hash.* where city not in ('Seoul','Daejeon');

delete from hash.* where city glob 'Seo*';

delete from hash.* where city glob 'A*';

delete from hash.* where city not glob 'A*';

delete from hash.* where birthday like '19%';

delete from hash.* where birthday like '19%';

delete from hash.* where birthday not like '19%';


<< Delete ZSet Delete Hash Delete Stream >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.