Hadoop (ix)-hbase shell command

Source: Internet
Author: User

1. Enter the HBase command line./hbase Shell

2. Display the list of tables in HBase

3. Create a user table with info, data two column families
Create ' user ', ' info1 ', ' data1 '
Create ' user ', {NAME = ' info ', VERSIONS = ' 3 '}


4. Insert the information into the table:

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

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

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

Insert information into the user table, row key is rk0001, column family data adds pic column identifier, value is picture
Put ' user ', ' rk0001 ', ' data:pic ', ' picture '


5. Get the information in the table:

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

Gets all the information for row key in the user table for the 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 ' user ', ' 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 ' people ', ' rk0002 ', {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 ') '}


6. Query the information in the table:

Querying all information in the user table
Scan ' user '

Querying information in the User table for column family info
Scan ' People ', {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 ' People ', {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]}

7. Delete the data in the table:
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 '


8. Other operations

To modify a 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 '


Enabling 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 '

Hadoop (ix)-hbase shell command

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.