Recently, some hbase things were introduced during the testing of XX Project, hoping to record the process from the testing perspective and hope to help you quickly understand it. As a person who first came into contact with it, they need to grasp the basic concepts urgently and will not go into detail here.
Hbase shell is a convenient access method provided by hbase. First, you need to build an hbase environment. For more information, see
Http://hbase.apache.org/book/quickstart.html and http://hbase.apache.org/book/notsoquick.html.
1. Go to the hbase shell command line interface
> Hbase Shell
Enter 'help' to quickly view the supported commands.
2. Create a table
> Create 'people', 'blood ', 'feature'
You can run the 'LIST' command to check whether the table has been successfully created.
3. Add Table records
> Put 'people', '1', 'blood: A', 'a is aaa'
> Put 'people', '1', 'blood: B ',' B is bbb'
> Put 'people', '1', 'blood: O', 'O is ooo'
> Put 'people', '1', 'blood: AB ',' AB is abab'
4. query by rowkey
> Get 'people', '1'
5. Update table records
• Query the pre-update Value
> Get 'people', '1', 'blood: AB'
• Update the value of 'AB' to 'a and B'
> Put 'people', '1', 'blood: AB ', 'a and B'
• Query the updated value
> Get 'people', '1', 'blood: AB'
• Query multiple 'AB' values
> Get 'people', '1', {Column => 'blood: AB ', versions => 2}
• To query one of the versions, use Timestamp
> Get 'people', '1', {Column => 'blood: AB ', timestamp => 1406198779063}
6. Delete table records
• Delete can only delete one column
> Delete 'people', '1', 'blood: AB'
• Delete all columns of rowkey with deleteall
> Deleteall 'people', '1'
• Delete a table
> Disable 'others'
> Drop 'others'
You must disable the table before deleting it.
Summary
The above demonstrates how to use hbase shell to add, delete, modify, query, and create and Delete tables for records. You can refer to your own exercises to learn the principles and knowledge points.