Hbase Shell Operations Summary

Source: Internet
Author: User

Enter HBase command line
./hbase Shell

Show tables in HBase
List

Create a user table with info, data two column families
Create ' users ', ' info ', ' data '
You can also use the This command:
Create ' users ', {NAME = ' info ', VERSIONS = ' 3 '}

Insert information into the table, row key is rk0001, column family info adds the Name column identifier, and the value is Zhangsan
Put ' users ', ' rk0001 ', ' info:name ', ' Zhangsan '

Insert information into table, row key is rk0001, column family info adds gender column identifier, value is female
Put ' user ', ' rk0001 ', ' info:gender ', ' female '

Insert information into table, row key is rk0001, column family info Adds an age column identifier value of 20
Put ' user ', ' rk0001 ', ' info:age ', 21

Get all the information for row key rk0001 in the table
Get ' user ', ' rk0001 '

Get all information for row key in table rk0001,info column family
Get ' user ', ' rk0001 ', ' info '

Gets information about the name, age column identifier of row key in the user table for the Rk0001,info column family
Get ' user ', ' rk0001 ', ' info:name ', ' info:age '

Gets the information for row key rk0001,info, data column family in the user table
Get ' USERS ', ' rk0001 ', ' INFO ', ' DATA '
Get ' user ', ' rk0001 ', {COLUMN = = [' Info ', ' data '}

Get ' user ', ' rk0001 ', {COLUMN = = ' Info:name ', ' data:pic '}

Gets the information of the user table in row key rk0001, the column family is info, the version number is the latest 5
Get ' user ', ' rk0001 ', {COLUMN = ' info ', VERSIONS = 2}
Get ' user ', ' rk0001 ', {COLUMN = ' info:name ', VERSIONS = 5}
Get ' user ', ' rk0001 ', {COLUMN = ' info:name ', VERSIONS = 5, Timerange = [1392368783980, 1392380169184]}

Gets the information for the value of Zhangsan for row key Rk0001,cell in the user table
Get ' people ', ' rk0001 ', {FILTER = ' valuefilter (=, ' binary: Picture ') '}

Gets the information in the user table for row key rk0001, which contains a in the column designator
Get ' people ', ' rk0001 ', {FILTER = ' (Qualifierfilter (=, ' substring:a ')) "}

Put ' user ', ' rk0002 ', ' info:name ', ' fanbingbing '
Put ' user ', ' rk0002 ', ' info:gender ', ' female '
Put ' user ', ' rk0002 ', ' info:nationality ', ' China '
Get ' user ', ' rk0002 ', {FILTER = ' valuefilter (=, ' binary: China ') '}

Querying all information in the user table
Scan ' user '

Querying information in the User table for column family info
Scan ' user ', {COLUMNS = ' info '}
Scan ' user ', {COLUMNS = ' info ', RAW = true, VERSIONS = 5}
Scan ' Persion ', {COLUMNS = ' info ', RAW = true, VERSIONS = 3}
Querying information for column families in the user table for info and data
Scan ' user ', {COLUMNS + = [' info ', ' data '}
Scan ' user ', {COLUMNS = [' Info:name ', ' Data:pic ']}

Querying the user table for information about the column family is info, and the column identifier is name
Scan ' user ', {COLUMNS = ' info:name '}

Query the user table for information about the column family as info, the column identifier name, and the latest version of the 5
Scan ' user ', {COLUMNS = ' info:name ', VERSIONS = 5}

Query for information in the user table that has the column family as info and data and that contains the a character in the column identifiers
Scan ' user ', {COLUMNS + = [' info ', ' data '], FILTER = ' (Qualifierfilter (=, ' substring:a ')) '}

Querying data in the user table for a column family of Info,rk range is [rk0001, rk0003)
Scan ' People ', {COLUMNS = ' info ', StartRow = ' rk0001 ', Endrow = ' rk0003 '}

Query the user table for row key starting with the RK character
Scan ' user ',{filter=> ' prefixfilter (' RK ')}

Querying data from a specified range in the user table
Scan ' user ', {timerange = [1392368783980, 1392380169184]}

Delete data
Delete the user table row key is rk0001, and the column designator is info:name data
Delete ' People ', ' rk0001 ', ' info:name '
Delete the user table row key is rk0001 and the column identifier is info:name,timestamp 1392383705316 data
Delete ' user ', ' rk0001 ', ' info:name ', 1392383705316

Emptying data in the user table
Truncate ' People '

Modify Table Structure
First Deactivate user table (new version not available)
Disable ' user '

Add two column families F1 and F2
Alter ' people ', NAME = ' F1 '
Alter ' user ', NAME = ' F2 '
Enable table
Enable ' user '

Disable ' user ' (new version not available)
Delete a column family:
Alter ' user ', NAME = ' F1 ', METHOD = ' delete ' or alter ' user ', ' delete ' = ' F1 '

Add Column Family F1 also delete column family F2
Alter ' user ', {name = ' F1 '}, {name = ' F2 ', METHOD = ' Delete '}

Change the F1 column family version number of the user table to 5
Alter ' people ', NAME + ' info ', VERSIONS = 5
Enable table
Enable ' user '

Delete a table
Disable ' user '
Drop ' user '

get ' person ', ' rk0001 ', {filter = ' valuefilter (=, ' binary: China ') '} 
get ' person ', ' rk0001 ', {filter = = ' (Qu Alifierfilter (=, ' substring:a ')) "} 
Scan ' person ', {COLUMNS = ' info:name '} 
Scan ' person ', { COLUMNS = [' info ', ' data '], FILTER = "(Qualifierfilter (=, ' substring:a ')"} 
Scan ' person ', {COLUMNS = > ' info ', StartRow = ' rk0001 ', Endrow = ' rk0003 '}

Scan ' person ', {COLUMNS = ' info ', StartRow = ' 20140201 ', Endrow = ' 20140301 '}
Scan ' person ', {COLUMNS = ' info:name ', timerange = [1395978233636, 1395987769587]}
Delete ' person ', ' rk0001 ', ' info:name '

Alter ' person ', NAME = ' FFFF '
Alter ' person ', NAME = ' info ', VERSIONS = 10

Get ' user ', ' rk0002 ', {COLUMN = = ' Info:name ', ' data:pic '}


Hbase Shell Operations Summary

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.