Hbase Shell Details
HBase provides users with a very convenient way to use it, which we call "HBase Shell." The HBase shell provides most hbase commands, which can be easily created, deleted, and modified by HBase shell users, as well as adding data to tables, listing related information in tables, and so on. Note: When you write the HBase shell command incorrectly, delete it with "delete" on the keyboard, "Backspace" does not work. After HBase is started, the user can enter the HBase Shell with the following command, as follows:
[Email protected]:~$ hbase shellhbase Shell; Enter‘Help<return>‘ForList of supported commands. Type"Exit<return>"To leave the HBase shellversion0.94.3, r1408904, Wed Nov1419:55:11 UTC 2012hbase (Main): 001:0>
The specific HBase shell commands are shown in table 1.1-1 below:
Below we will use the example of "A Student score table" to detail the commonly used HBase commands and how they are used.
Here grad for the table is a column, course for the table is a column family, this column family consists of three columns China, math and Chinese, of course, we can according to our needs in the course to build more column family, such as Computer,physics Add the course column family to the corresponding column. (Note: The columns under the column family can also have no names.) ) 1). The Create command creates a table "scores" with two column families "Grad" and "course". The table names, rows, and columns are enclosed in single quotation marks and separated by commas. HBase (main):012:0> create ' scores ', ' name ', ' Grad ', ' course '
2). The list command to see which tables are in the current HBase. HBase (main):012:0> list
3). Describe command to view the construction of the table "scores". HBase (main):012:0> describe ' scores '
4). The put command uses the put command to insert data into the table, with parameters such as table name, row name, column name, and value, which require the most prefix of the column family before the column name, and the timestamp is automatically generated by the system. Format: Put table name, row name, column name ([Column family: Column name]), value example: A. Add one row of data, row name "Xiapi", column Family "grad" column named "(Empty string)", value bit 1. HBase (main):012:0> put ' scores ', ' Xiapi ', ' Grad: ', ' 1 ' hbase (main):012:0> put ' scores ', ' Xiapi ', ' Grad: ', ' 2 '--Modify operation (update) B. Add a column "<china,97>" to the column family "course" of the data for the line "Xiapi". HBase (main):012:0> put ' scores ', ' Xiapi ', ' Course:china ', ':012:0> ' hbase (main) ' scores put ', ' the ' ' ", ' The Xiapi ', ' course:m ' Ath ', ':012:0> ' hbase (main) put ' scores ', ' Xiapi ', ' course:english ', ' 85 '
5). Get command A. View data about the row "Xiapi" in Table "scores". HBase (main):012:0> get ' scores ', ' Xiapi ' B. View the value of the table "scores" Row "Xiapi" column "Course:math". HBase (main):012:0> get ' scores ', ' Xiapi ', ' Course:math ' or hbase (main):012:0> get ' scores ', ' Xiapi ', {column=> ' Course:math '} hbase (main):012:0> get ' scores ', ' Xiapi ', {columns=> ' Course:math '} Remarks: COLUMN and COLUMNS are different, scan The COLUMNS in the operation specifies the column family of the table, and the column in the get operation specifies the specific columns, and the value of COLUMNS is essentially the column family: column modifier.COLUMN and COLUMNS must be uppercase.
6). Scan command A. View all data in the table "scores". HBase (main):012:0> scan ' scores ' Note: The scan command can specify startrow,stoprow to scan multiple row. For example: Scan ' User_test ', {COLUMNS = ' info:username ', LIMIT =>10, startrow = ' test ', stoprow=> ' test2 '} B. View Table " Scores all data in the column family "course". HBase (main):012:0> scan ' scores ', {COLUMN = ' grad '} hbase (main):012:0> scan ' scores ', {column=> ' Course:mat H '} hbase (main):012:0> scan ' scores ', {COLUMNS = ' course '} hbase (main):012:0> scan ' scores ', {COLUMNS = ' C Ourse '}
7). Count Command HBase (main):068:0> count ' scores '
8). Exists command HBase (main):071:0> exists ' scores '
9). INCR command (assigned value)
Delete command deletes the behavior "xiaoxue" in Table "scores", and "math" in the column Family "course". HBase (main):012:0> delete ' scores ', ' Xiapi ', ' Course:math '
ONE). Truncate command HBase (main):012:0> truncate ' scores '
The. Disbale, Drop command deletes the "scores" table through the "Disable" and "drop" commands. HBase (Main):012:0> disable ' scores '--enable ' scores 'hbase (Main):012:0> drop ' scores '
). Status Command HBase (main):072:0> status
. Version command HBase (main):073:0> version
In addition, in the shell, constants do not need to be quoted, but binary values require double quotation marks, while others are enclosed in single quotation marks. The constants of the HBase shell can be entered by "object.constants" in the shell.
Hbase Shell Details