# kvql - 키-밸류 DB를 위한 SQL과 비슷한 쿼리 언어

> Clean Markdown view of GeekNews topic #14749. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=14749](https://news.hada.io/topic?id=14749)
- GeekNews Markdown: [https://news.hada.io/topic/14749.md](https://news.hada.io/topic/14749.md)
- Type: news
- Author: [xguru](https://news.hada.io/@xguru)
- Published: 2024-05-11T09:41:01+09:00
- Updated: 2024-05-11T09:41:01+09:00
- Original source: [github.com/c4pt0r](https://github.com/c4pt0r/kvql)
- Points: 9
- Comments: 0

## Topic Body

- SELECT, PUT, DELETE 로 조회,삽입,삭제 가능   
```  
# 간단한 쿼리, 키 접두사 'k'가 포함된 모든 키-값 쌍 가져오기  
select * where key ^= 'k'  
  
# 프로젝션 및 복잡한 조건식   
select key, int(value) + 1 where key in ('k1', 'k2', 'k3') & is_int(value)  
  
# 어그리게이션 쿼리   
select count(1), sum(int(value)) as sum, substr(key, 0, 2) as kprefix where key between 'k' and 'l' group by kprefix order by sum desc  
  
# JSON   
select key, json(value)['x']['y'] where key ^= 'k' & int(json(value)['test']) >= 1  
select key, json(value)['list'][1] where key ^= 'k'  
  
# select 문에 정의된 필드 이름으로 필터링   
select key, int(value) as f1 where f1 > 10  
select key, split(value) as f1 where 'a' in f1  
select key, value, l2_distance(list(1,2,3,4), json(value)) as l2_dis where key ^= 'embedding_json' & l2_dis > 0.6 order by l2_dis desc limit 5  
  
# 데이터 넣기   
put ('k1', 'v1'), ('k2', upper('v' + key))  
  
# 필터로 데이터 삭제 및 삭제 행 수 제한   
delete where key ^= 'prefix' and value ~= '^val_' limit 10  
delete where key in ('k1', 'k2', 'k3')  
```

## Comments



_No public comments on this page._
