Reputation: 3609
I would like to know some basics about hbase shell commands.
I created a hbase table as below.
create 'employee' ,'personaldetails'
I inserted some rows and added some columns.
put 'employee','1000','personaldetails:name','surender'
put 'employee','1000','personaldetails:age','27'
put 'employee','1001','personaldetails:name','raja'
put 'employee','1001','personaldetails:age','30'
Now I need to get rowkey data from table employee based on two columns or one column
The below command is throwing error. Also let me know how to include two conditions based on column
get 'employee',1001,'personaldetails:name','surender'
Upvotes: 0
Views: 1406
Reputation: 709
yes you can add new column family after creating table, do following to add new column family.
disable 'employee'
alter 'employee', 'new column family name' // new column family will be added into table.
enable 'employee'
And to query on the base of column value use filter, please look into following code to do it.
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.util.Bytes
get 'employee', 1000, {FILTER => SingleColumnValueFilter.new(Bytes.toBytes('personaldetails'), Bytes.toBytes('age'), CompareFilter::CompareOp.valueOf('EQUAL'), SubstringComparator.new('27'))}
Hope it will help you.
Upvotes: 1
Reputation: 7576
Can I add new column family after I created a hbase table?
Yes. Look into ALTER.
What is the hbase command to take a rowkey and column data based on two columns
Something like a WHERE clause? Look into how to scan hbase from hbase shell using filter.
Are you sure HBase is the right database for what you're doing? Employee databases tend to fit into RDBMSes quite well.
Upvotes: 0