1. Enter the HBase shell into the hbase shell
2. Create a table:
Command format: Create ' table name ', ' column family name 1 ', ' column family name 2 ', ' column family name N '
Create a table with a table name of users and a column family name of sex and info
3. Use the List command to view the table you just built
4. Add Data:
Command format: Put ' table name ', ' Row name ', ' column family name ' (case of column family with only one column)
Or put ' table name ', ' Row name ', ' column family name: Column name ' (Case of column family multiple columns)
The ' Sex ' column family has only one column
The ' Info ' column family has two columns, and of course there are more
5. View all of the table's information in the table
Command format 1:scan ' users '
Command format 2:scan ' users ',{column=> ' column family '} (will display all information in the ' users ' table with the column family name ' info ')
Command format 3:scan ' users ',{column=> ' column family: Column name '} (will display information for column family name ' info ' in ' users ' table and column named ' Age ')
6. View the total number of records in a table
Command format: Count ' table name '
(only data with row name Xiaozhong)
Here, we're going to insert a Xiaomeng data.
Put ' users ', ' xiaoming ', ' sex ', ' male '
Put ' users ', ' xiaoming ', ' info:age ', ' 20 '
Put ' users ', ' xiaoming ', ' Info:tel ', ' 987654321 '
Then we'll look at the total number of records in the table.
(Two records, respectively Xiaozhong and xiaoming)
7. Update the data (also using the put command, equivalent to overwrite)
Command format: Put ' table name ', ' Row name ', ' column family name '
Or put ' table name ', ' Row name ', ' column family name: column name '
The age of update Xiaozhong is 22
8. View version Information
Command format: Get ' table name ', ' Row name ',{column=> ' column family ', versions=>n} (case of column family with only one column)
Or get ' table name ', ' Row name ',{column=> ' column family: Column family name '} (case of column family with multiple columns)
N: All views of the version (if not versions=>n, the default display of the latest data, N default maximum is 3)
9. Deleting records
Command format:
Delete ' table name ', ' Row name ' (Delete xiaoming information for this line)
Delete ' table name ', ' Row name ', ' column family name ' (delete a column family of xiaoming information)
Delete ' table name ', ' Row name ', ' column family name: Column name ' (Removes a column of information from a column family of Xiaoming)
Truncate ' table name ' (Empty table)
10. Delete a table
Before deleting a table, first set the table to Disabled before deleting
Command format: Disable ' table name '
Drop ' table name '
Basic operations for HBase