HBase Tutorial (ii) HBase database Shell command
1 Hbase-shell Command
HBase is a distributed, column-oriented open source database, HBase also provides the shell command of the database to add, delete, change, check the basic operations, such as database creation, modification, delete, modify the operation, data insertion, deletion, modification and so on.
Execute command: HBase shell, enter HBase database
1.1 hbase help command
Execute on the command line: Help [' Command '], view the assistance command:
1.2 General Operation
1,Status: Query Server Status:
Usage: status
2,whoami: Query the current User:
Usage: WhoAmI
3,version: The current hbase to use the edition number:
Usage: Version
1.3 DDL Operations
1,create: Creating database tables, creating commands to see Help ' create '
Syntax: Create <table>, {NAME =><family>, versions => <versions>}
Example: Create ' product ', {name => ' computer ', versions => 5},{name => ' food ', versions => 3}
Description: Create a table named ' Product ' database, and create two column families, respectively: ' Computer ', ' food '
2.List: View existing tables
Usage: List
3.describe: View table structure description
Usage: Describe ' product '
4.Alter: Modify the table
Usage: Modify table structure must first disable, then modify the table, after the modification, then the Enable table.
Disable ' product '
Alter ' product ', {NAME => ' food ',versions=> 3}
Enable ' product '
5.Drop: Delete table
Usage: First disable, then drop.
Disable ' product '
Drop ' product '
1.4 DML Operations
1.put: Insert data
Grammar: Put <table>,<rowkey>,<family:column>,<value>,<timestamp>
Example: Put ' product ', ' rowkey001 ', ' computer:name ', ' ThinkPad E550 '
Insert data again: Put ' product ', ' rowkey001 ', ' Computer:price ', 4199
Description: Adds a row to the table ' product ': Rowkey is ' rowkey001 ', family name: ' Computer ', column name: ' Name ', Value: ' ThinkPad E550 ', Timestamp: system default
Insert two data, actually add two columns, return or a piece of data
2,scan: Scan table
Syntax: Scan <table>,{columns => [<family:column>,....], LIMIT => num}
HBase storage data is stored in binary form, reading is not a problem
Example: Scan ' product '
3,get: Query data
Grammar:get<table>,<rowkey>,[<family:column>,....]
Query the value of a cell under computer in the table product,rowkey001
Example: Get ' product ', ' rowkey001 '
Example: Get ' product ', ' rowkey001 ',{column=> ' computer:name '}