HBASE Common shell commands, additions and deletions to search

Source: Internet
Author: User
First give the data of this operation
Create ' student ', ' info ', ' address '
put ' student ', ' 1 ', ' info:age ', ' Put '
student ', ' 1 ', ' info:name ', ' Wang '
put ' student ', ' 1 ', ' info:class ', ' 1 '
put ' student ', ' 1 ', ' address:city ', ' Zhengzhou '
put ' student ', ' 1 ', ' Address:area ', ' high-tech zone '
put ' student ', ' 2 ', ' info:age ', ' Put '
student ', ' 2 ', ' info:name ', ' Yang '
put ' student ', ' 2 ', ' Info:class ', ' 1 '
put ' student ', ' 2 ', ' address:city ', ' Beijing '
put ' student ', ' 2 ', ' Address:area ', ' CBD '
put ' student ', ' 3 ', ' info:age ', ' Put '
student ', ' 3 ', ' info:name ', ' Zhao '
put ' Student ', ' 3 ', ' Info:class ', ' 2 '
put ' student ', ' 3 ', ' address:city ', ' Shanghai '
put ' student ', ' 3 ', ' Address: Area ', ' Pudong '
scan ' student '

2. First Execute, CREATE TABLE, add data operation, execute script/bin/hbase shell./student.txt, then view content scan ' student '

HBase (main):001:0> scan ' student ' ROW Column+cell 1 Column=address:area , timestamp=1491533426260, Value=high-tech Zone 1 column=address:city, timestamp=1491533426239, V Alue=zhengzhou 1 column=info:age, timestamp=1491533426179, value=20 1 Co Lumn=info:class, timestamp=1491533426218, value=1 1 column=info:name, timestamp=1491533426211, VA Lue=wang 2 Column=address:area, timestamp=1491533426297, VALUE=CBD 2 col Umn=address:city, timestamp=1491533426292, value=beijing 2 column=info:age, timestamp=14915334262 VALUE=21, 2 Column=info:class, timestamp=1491533426287, value=1 2 col Umn=info:name, timestamp=1491533426277, Value=yang 3 Column=address:area, timestamp=1491533426329       , Value=pudong 3                  Column=address:city, timestamp=1491533426323, Value=shanghai 3 column=info:age,                         timestamp=1491533426305, value=22 3 Column=info:class, timestamp=1491533426317, value=2 3
 Column=info:name, timestamp=1491533426311, Value=zhao 3 row (s) in 0.1940 seconds

3. The modification operation is also to use the put command, that is, to re-add the content to overwrite the previous content.

Format put ' t1 ', ' R1 ', ' C1 ', ' value '
Command put ' student ', ' 1 ', ' info:age ', ' 18 '
Results
hbase (main):010:0> get ' student ', ' 1 '
COLUMN                     CELL
 address:area              timestamp=1491533426260, Value=high-tech Zone
 address:city              timestamp=1491533426239, Value=zhengzhou
 info:age                  timestamp= 1491533823331, value=18
 info:class                timestamp=1491533426218, value=1
 info:name                 timestamp= 1491533426211, Value=wang
5 row (s) in 0.0110 seconds

4. Delete operation, divided into delete the contents of the cell, and the whole row delete
Cell

HBase (main):012:0> delete ' student ', ' 1 ', ' Info:name '
0 row (s) in 0.0800 seconds

hbase (main):014:0> get ' Student ', ' 1 '
COLUMN                     CELL
 address:area              timestamp=1491533426260, Value=high-tech zone
 address: City              timestamp=1491533426239, Value=zhengzhou
 info:age                  timestamp=1491533823331, value=18
 info: Class                timestamp=1491533426218, value=1
4 row (s) in 0.0120 seconds

Entire row

HBase (Main):023:0> DeleteAll ' student ', ' 1 '
0 row (s) in 0.0260 seconds

hbase (main):024:0> get ' student ' , ' 1 '
COLUMN                     CELL
0 Row (s) in 0.0070 seconds

5. Enquiry

Single-line Query

HBase (main):026:0> get ' student ', ' 2 '
COLUMN                     CELL
 address:area              timestamp=1491533426297, value= CBD
 address:city              timestamp=1491533426292, value=beijing
 info:age                  timestamp=1491533426269, value=
 info:class                timestamp=1491533426287, value=1
 info:name                 timestamp=1491533426277, Value=yang
5 row (s) in 0.0190 seconds

Specifying column families

HBase (main):028:0> get ' student ', ' 2 ', {column = ' info '}
column                     CELL
 info:age                  timestamp= 1491533426269, value=21
 info:class                timestamp=1491533426287, value=1
 info:name                 timestamp= 1491533426277, Value=yang
3 row (s) in 0.0150 seconds

Specify Column Name

HBase (main):029:0> get ' student ', ' 2 ', {column = ' info:age '}
column                     CELL
 info:age                  timestamp= 1491533426269, value=21
1 row (s) in 0.0080 seconds

Using Scan, specify StartRow

HBase (main):031:0>  scan ' student ', {COLUMNS = [' Info:age ', ' address '], LIMIT = ten, StartRow = ' 2 '}
  
   row                        Column+cell
 2                         column=address:area, timestamp=1491533426297, VALUE=CBD
 2                         column= Address:city, timestamp=1491533426292, value=beijing
 2                         column=info:age, timestamp=1491533426269, value=
 3                         Column=address:area, timestamp=1491533426329, Value=pudong
 3                         column=address:city, timestamp=1491533426323, Value=shanghai
 3                         column=info:age, timestamp=1491533426305, value=22
2 Row (s) in 0.0190 seconds

  

Scan specified filter

HBase (main):005:0> scan ' student ',{filter=> "(Timestampsfilter (1491533426297))"}
ROW                        Column+cell
 2                         Column=address:area, timestamp=1491533426297, VALUE=CBD
1 row (s) in 0.0170 seconds
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.