HBase common basic commands

Time:2021-10-22

HBase table structure

HBase common basic commands

1. Enter the HBase shell

>./bin/hbase shell

2. View the current operating user

> whoami

3. Create a table

//Table 1 column 2
> create 'Rumenz','user','userInfo'

4. View database tables

> list

5. Add data

//Table name rowkey column family: field name value
>Put 'rumenz', '001', 'user: name', 'entry station'
> put 'Rumenz','001','user:type','1'

6. Number of query record lines

> count 'Rumenz'

7. Query records through row key

//Table name row key
> get 'Rumenz','001'

8. Query data through row key and column family

//Table name row key column family    
> get 'Rumenz','001','user'

9. Query all records in the table

//Table name
> scan 'Rumenz'

10. View only the data of a column

> scan 'Rumenz',{COLUMN=>'user:name'}

11. View only the data of a column family

> scan 'Rumenz',{COLUMN=>'user'}

12. Paging query

//Start row, limit = > 1 take a piece of data, and versions = 1 query the latest version
> scan 'Rumenz',{STARTROW=>'001',LIMIT=>1,VERSIONS=1}

13. Delete a column value in a column

//User: name is the field name                       
> delete 'Rumenz','001','user:name'

14. Delete the value of a row (via row key)

//001 is row key
> deleteall 'Rumenz','001'
  1. Update data
>Put 'rumenz', '002', 'user: name', 'new value'

16. Adding families

> alter 'Rumenz','depart'

17. Delete column family

> alter 'Rumenz','delete'=>'depart'

18. The column family cannot be renamed (you can create a new column family, copy the value, and then delete the old column family)

19. Table renaming

//Table in HBase has no rename operation
//1. Table insertion is prohibited
> disable 'Rumenz'
//2. Take a snapshot
> snapshot 'Rumenz','RumenzShot'
//3. Clone the snapshot to a new name
> clone_snapshot 'RumenzShot','RumenzNew'
//4. Delete snapshot
> delete_snapshot 'RumenzShot'
//5. Delete the original table
> drop 'Rumenz'

20. Delete table

//1. Table insertion is prohibited
> disable 'RumenzNew'
> drop 'RumenzNew'

21. Check whether a table exists

> exists 'RumenzNew'

22. View table structure

> desc 'RumenzNew'

HBase common basic commands

Recommended Today

Swift advanced (XV) extension

The extension in swift is somewhat similar to the category in OC Extension can beenumeration、structural morphology、class、agreementAdd new features□ you can add methods, calculation attributes, subscripts, (convenient) initializers, nested types, protocols, etc What extensions can’t do:□ original functions cannot be overwritten□ you cannot add storage attributes or add attribute observers to existing attributes□ cannot add parent […]