1. HBase provides a shell terminal to interact with the user
2. The DDL operation of the HBase shell
(1) Enter HBase shell command line first, that is hbase_home/bin/hbase shell ... >quit
To Create a table:>create'Users','user_id','Address','Info' //table users, there are three column families User_id,address,info
List all tables:>the list gets a description of the table:>describe'Users'To Create a table:>create'users_tmp','user_id','Address','Info'To Delete a table:>disable'users_tmp'>drop'users_tmp'
(2) Add records, Get records, update records
add record: Put'Users','xiaoming','Info:age',' -'; Put'Users','xiaoming','Info:birthday','1987-06-17'; Put'Users','xiaoming','Info:company','Alibaba'; Put'Users','xiaoming','Address:contry',' China'; Put'Users','xiaoming','address:province','Zhejiang'; Put'Users','xiaoming','address:city','Hangzhou'; Put'Users','Zhangyifei','Info:birthday','1987-4-17'; Put'Users','Zhangyifei','Info:favorite','movie'; Put'Users','Zhangyifei','Info:company','Alibaba'; Put'Users','Zhangyifei','Address:contry',' China'; Put'Users','Zhangyifei','address:province','Guangdong'; Put'Users','Zhangyifei','address:city','Jieyang'; Put'Users','Zhangyifei','Address:town','Xianqiao'; Gets a record:1. Get all the data for an ID:>Get 'Users','xiaoming'2. Gets all the data for an ID, a column family:>Get 'Users','xiaoming','Info'3. Gets an ID for one column in a column family: all dataGet 'Users','xiaoming','Info:age'
Update Record:>put'Users','xiaoming','Info:age',' in'>Get 'Users','xiaoming','Info:age'>put'Users','xiaoming','Info:age',' -'>Get 'Users','xiaoming','Info:age'get version data for cell data:>Get 'Users','xiaoming',{column=>'Info:age',versions=>1} >Get 'Users','xiaoming',{column=>'Info:age',versions=>2} >Get 'Users','xiaoming',{column=>'Info:age',versions=>3get a version of the cell data )Get 'Users','xiaoming', {column=>'Info:age',timestamp=>1364874937056} full table scan:>scan'Users'
(3) Delete
Delete the xiaoming value of the'Info:age'fields:>delete'Users','xiaoming','Info:age'>Get 'Users','xiaoming'To delete an entire row:>deleteall'Users','xiaoming'number of rows in the statistics table:>count'Users'Clear the table:>truncate'Users'
The shell command for HBase