I want to delete all tables in HBase. I am using HBase shell commands for doing this operation:
$ hbase shell
> disable_all .*
> drop_all .*
How can i write a shell script for doing this operations ?
Note: While executing above commands, it asks for the user confirmation i.e y/n before disabling and dropping all tables.
Deleting All Cells in a Table. Using the “deleteall” command, you can delete all the cells in a row. Given below is the syntax of deleteall command.
To access the HBase shell, you have to navigate to the HBase home folder. You can start the HBase interactive shell using “hbase shell” command as shown below. If you have successfully installed HBase in your system, then it gives you the HBase shell prompt as shown below.
A column qualifier identifies a single column within a column family. There can be multiple time-stamped cells at the intersection of a row and column. Type exit and press Enter to exit the HBase shell.
I use the following:
#!/bin/sh
echo -e "disable_all '.*'\ny" | hbase shell -n
echo -e "drop_all '.*'\ny" | hbase shell -n
The -e
flag to echo causes it to process escape sequences so you can build the confirmation into it. The -n
tells hbase shell this is a non-interactive session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With