Eric H.
Eric H.

Reputation: 341

HBase - difference between drop table and delete table?

I am learning HBase shell commands and getting confused by drop and delete table.

Could anyone comment on the difference between dropping a table and deleting a table?

thanks.

Upvotes: 3

Views: 8214

Answers (3)

JayPadhya
JayPadhya

Reputation: 65

There is a basic difference :

  • delete is used to delete a particular cell in a table and hence you can't run delete on a table directly and expect it to be deleted.

  • drop will drop the entire table without any reference to cell without disabling a table first.

From the image - you can see that hbase suggested that delete should be accompanied with cell reference as well and drop simply dropped the table and there is no table after that command.

HBase delete/drop difference

Upvotes: 1

Hafiz Muhammad Shafiq
Hafiz Muhammad Shafiq

Reputation: 8678

Just for some addition. In other to delete a table via hbase shell or java api. first you have to disable table then drop. Otherwise table could not be deleted.

Upvotes: 0

mdahlman
mdahlman

Reputation: 9410

There's no difference. I speculate that the reason for the two names is because HBaseAdmin was created first, and it used "delete". Then when the shell was created folks realized that drop table tablename is the standard way to get rid of a table.*

But I confirm (regardless of the speculation into its origin) that they are the same by looking at the HBase Admin source file admin.rb:

# Drops a table
def drop(table_name)
  tableExists(table_name)
  raise ArgumentError, "Table #{table_name} is enabled. Disable it first.'" if enabled?(table_name)
  @admin.deleteTable(table_name)
end

*But to be precise... they did not go with drop table tablename but rather drop 'tablename' in the HBase shell.

Upvotes: 3

Related Questions