HBase Note 3 shell command

Source: Internet
Author: User

1.HBase Shell and we use the MySQL terminal is a means, such as we installed MySQL, CONFIGURED environment variables, command line input mysql-uroot-p password can be directly into the MySQL
The terminal, where HBase is also a meaning.

How to enter HBase terminal, use the command hbase Shell to enter the command line mode. Here, we can operate on HBase is very limited, in PPT19, basically contains his 80% or 90% of operations.
There are no complex queries, because complex queries are not the strong point of hbase, but they can be easily queried for massive amounts of data.


PPT19 also has a display
Creating table create ' table name ', ' column family name 1 ', ' column family name 2 ', ' column family name N '
Add record put ' table name ', ' Row name ', ' Column name: ', ' value ' (if not write timestamp, default current time)
View record get ' table name ', ' Row key name '
View the total number of records in a table count ' table name '
Delete record delete ' table name ', ' Row key name ', ' column name ' (delete the entire column corresponding to the specified line)
Delete a table to block the table before you can delete it, the first step disable ' table name ' Second step drop ' table name '
View all records scan "table name" (full table scan, similar to select * from table name)
View all data in a column of a table scan table name, {columns=> ' column family name: column name '}
Update a record to overwrite it again or use the put operation

Here are some examples:
Creating the table: Create ' user ', ' user_id ', ' adress ', ' info '
When creating a table, both the table name and the column family name need to be quoted, separated by commas between the table and column family, the column family and the column family, ending with a semicolon end
View table: List
List command: See what tables you have, this command lists the names of the tables, with no specific content.
View table details: Describe ' user '
Describe table names to see specific information for a table, the table name needs to be enclosed in quotation marks.
This command will show a lot of things, although we create the table is very simple, but it has a lot of default values, here with this command, will show you.
The contents of the display are divided into two parts, the left caption is description, which is the details of the table, and the right is enable to show whether the table is enabled or not. On the left.
In the details section, the first is the name of the table, and then there will be a lot of curly braces, each of which is the information of the column family, and we only specify the name of the column cluster when we create the table.
None of the others have been specified, but they all have default values, which are shown here as well. If we learn in depth, in fact, when creating a table, it can not be as simple as above,
These parameters can be set.
Delete table: Disabled ' user '
Drop ' user '
Insert record: Put ' user ', ' Zhangyifei ', ' address:city ', ' Beijing '
Put ' user ', ' Zhangyifei ', ' info:age ', ' 22 '
Get record: Get ' user ', ' Zhangyifei '
Get ' user ', ' zhangyifei ', ' adress '
Update record: Put ' user ', ' Zhangyifei ', ' info:age ', ' 24 '
Put ' user ', ' Zhangyifei ', ' info:age ', ' 25 '
Put ' user ', ' Zhangyifei ', ' info:age ', ' 26 '
Put ' user ', ' Zhangyifei ', ' info:age ', ' 27 '
Get ' user ', ' Zhangyifei ', ' info:age ' Verify that the data update was not successful (the latest value is displayed by default)
Get version info get ' user ', ' Zhangyifei ', ' {column=> ' Info:age ', VERSIONS} show the latest version
Get ' user ', ' Zhangyifei ', ' {column=> ' Info:age ', versions=>2} are showing the latest 2 versions
Get ' user ', ' Zhangyifei ', ' {column=> ' Info:age ', versions=>3} show the latest 3 versions
Get ' user ', ' Zhangyifei ', ' {column=> ' Info:age ', versions=>4} shows the latest 4 versions, but does not show 4 versions, showing only 3, which we previously
Did insert 4 times AH (24, 25, 26, 27) because: we use the describe command
When viewing the details of a table, in that curly brace is a description of the column cluster information,
One of these is the number of versions (versions=> ' 3 '), which we did not specify when we created the table, which by default
Yes 3 can be changed to 4, but it is the time to create the table. Specifically how to write it, in fact, is to
Description The following things to copy, and then add a create on the front line.
Create ' user ',{name=> ' info ',versions=> ' 5 '},{name=>,version=>},{} ...

Get a version of the cell data get ' users ', ' xiaoming ',{column=> ' info:age ', timestamp=>1364874937056}
We need to know the time stamp here, if the time stamp is not specified, that is the time, but it is difficult for us to know what time is,
So we can specify what the timestamp is exactly.
Full table Scan: Scan ' user '


Get ' users ', ' xiaoming ',{column=> ' info:age ', version=>4}
Get ' users ', ' xiaoming ',{column=> ' info:age ', version=>1384092294281} take a specific value, that is, table name + column family: Column name + timestamp to determine a specific value
Timestamp if not specified at the time of insertion, he is based on the current time to calculate, then later in the search, we do not know when the current time when inserting, what to do. Timestamps can actually be specified at the time the data is inserted.
The number of versions needs to be specified when creating the table.
Scan table Scans Whole sheet

A GET command is a lookup of a row, which requires a table name and a row health
The Scan command is a full table scan of the table, specifying the table name when it is found

Remove a column delete ' users ', ' xiaoming ', ' info:age ' we will not affect other records when we delete the column, certainly not, because we have this command to indicate the line Jian Xiaoming
Delete a record (row) DeleteAll ' user ', ' xiaoming ' (deteleall table name, row health)
View the number of records (rows) of a table count ' user '
Clear table data: Truncate ' user '//is actually performing a 3-step operation, disabled, drop, create, at this time represents the existence, but there is no data

Two records in the same table, their column families are the same, but the columns in the column family may be different. So it can be said that the column belongs to the column family, also belong to the record, even if we have two rows of records, are in
There is a column with the same name under the same column family, and I don't think they have anything to do with it. We delete the column of one record and the other record is not affected.

HBase Note 3 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.