How to clear a table in hbase?

Micku picture Micku · Mar 28, 2012 · Viewed 29.4k times · Source

I want to empty a table in hbase... eg: user. Is there any command or function to empty the table without deleting it...

My table structure is :

$mutations = array(
                new Mutation( array(
                    'column' => 'username:1',
                    'value' =>$name
                ) ),
                new Mutation( array(
                    'column' => 'email:1',
                    'value' =>$email
                ) )
        );          
$hbase->mutateRow("user",$key,$mutations);

Can someone help me?

Answer

Alexis Gamarra picture Alexis Gamarra · Aug 1, 2013

If you execute this in HBase shell:

 > truncate 'yourTableName'

Then HBase will execute this operations for 'yourTableName':

 > disable 'yourTableName'
 > drop 'yourTableName'
 > create 'yourTableName', 'f1', 'f2', 'f3'