HBase에서 HQL 사용하기

less than 1 minute read

HBase에서 HQL 사용하기    (wiki.apache.org내용을 근거로)

설치된 HBase를 바탕으로, HQL을 수행하였다. (bin/hbase shell) 해당 정보의 참고 링크는 아래와 같다. http://wiki.apache.org/hadoop/Hbase/HbaseShell?action=print

  1. Create Table
    hql> create table movielog_table (
    -> year, length, inColor, studioName, vote, producer, actor);
    
  2. Insert Data
    hql> insert into movielog_table (year:, length:, inColor:, studioName:,
    'vote:user name', producer:, 'actor:hero')
    -> valules ('1977', '124', 'true', 'Fox', '5', 'George Lucas', 'Mark Hamill')
    -> where row = 'Star Wars';
    
  • 내가 해 본 시도)
  • column 명을 주지 않고, 곧바로 values들만 넣어봄 : 에러
  • where 부분에서 row key 를 지정하지 않음 : 당연히 에러!

  • row key가 따로 명시되지만, 사실 일반 PK 필드와 동일함.
  • 사용시 where 이후에 기록을 꼭해줘야 함. (활용폭이 적음, 맵 구조인지라 키를 중심으로 데이터를 처리함)
  • 관계형 DB에 비해 where 조건에 넣을 수 있는 실질적인 비교구문이 없음
  1. Select Data
    hql> select count(studioName:FOX) from movielog_table;
    
  2. Truncate
    hql> truncate table 테이블명
    
  3. Drop Table
    hql> drop table 테이블명
    
  • truncate나 drop table을 실행하기 전에 반드시 disable 테이블명을 해줘야 실행된다.

Leave a Comment