HBase

28 / 34

HBase Hands-On with console




Not able to play video? Try with youtube

Transcript: Let's login to the console. Start the Hbase interactive shell using:

hbase shell

We will be typing our HBase commands here. Let us first create a table with name as our login followed by underscore and then console. For our case since my login is sandeepgiri9034 the exact command is:

create 'sandeepgiri9034_console', 'contents','anchors'

Please note that all the strings which is table names and column families are surrounded by single quotes. You can see more commands by typing help. Now, let us add the first record. Add first cell - put tablename rowkey column identifier and then cell value, So the exact command is:

put 'sandeepgiri9034_console',  'com.cnn.www', 'contents:', '<h1> Welcome to CNN - Breaking news. </h1>'

Now, let's add the second and third column to the same row_key.

put 'sandeepgiri9034_console',  'com.cnn.www', 'anchors:si.com', 'CNN'

and then

put 'sandeepgiri9034_console',  'com.cnn.www', 'anchors:microsoft.com', 'CNN News'

To see the entire table, we can use scan, the exact command is:

scan 'sandeepgiri9034_console'

We can delete a table by first disabling it, so to delete my table I can use

disable 'sandeepgiri9034_console'

and again the name of the table or the name of the column family or the contents is surrounded by single quotes. Once disabled we can drop the table by using drop followed by table name:

drop 'sandeepgiri9034_console'

If we try to scan the deleted table, it would throw an error "Unknown table".

To see the list of tables you can use list command. You can also provide regular expression to filter out the results of list command by providing list space regular expression to match with the table name. For example list 'san.*' would list all the tables starting with "san". This regular expression that you see on the screen lists the tables ending with four digits.

To exit we simply press control d.


Loading comments...