Metadata
Metadata

Reputation: 2083

How to drop a column from a columnfamily in Hbase?

To drop a column family, we have below commands.

hbase> disable tablename
hbase> alter 'tablename',{NAME=>'COLFAM NAME',METHOD=>'delete}

If there is a columnfamily: 'empdetails' in a table 'emptable' with columns: 'col1,col2', is there a way to delete a particular column from a column family ? Im not going to implement it but this is just for my knowledge and to know if there is such possibility.

Upvotes: 2

Views: 15494

Answers (3)

dinesh028
dinesh028

Reputation: 2187

Refer this page it provides 3 solutions to delete a column from HBase table -

https://querydb.blogspot.com/2019/11/hbase-phoenix-cause-and-solution-for.html
  1. Unix Command
  2. Through Phoenix
  3. Hadoop Map Reduce

Upvotes: 0

Subash Kunjupillai
Subash Kunjupillai

Reputation: 400

If I would have got your question right, you want to delete column qualifier(s) under a column family.

As we know, during table creation we would define only the column family not the column qualifier. So the column qualifier will be created on the fly and it depends on the need. Which means you won't be having a column qualifier for all rows in that table. So there is no provision to delete column qualifiers for a particular column family.

There is provision to delete a row by two ways:

  1. delete : Which deletes a particular cell related to a row on providing all information about that like table, rowKey, column (family:qualifier), timestamp
  2. deleteall : Which deletes all cells related to a row on providing minimal information like table and rowKey

May be you can refer this link for exact syntax

Upvotes: 3

AM_Hawk
AM_Hawk

Reputation: 681

delete '{table name}', '{row}', '{column name}', '{time stamp}'

delete 'emp', '1', 'personal data:city', 1417521848375

The delete command can be used to delete certain columns.In order to delete an entire row including all of its columns, use delete all.To delete all the rows from a table, use truncate ‘tablename’. Under the hood, HBase will disable, drop, and re-create the table

  • delete column in a row: hbase> delete ”, ‘rowkey’, ‘col’ hbase> delete ‘t1’, ‘r1’, ‘fam1:c1’
  • delete an entire row hbase> delete ”, ‘rowkey’ hbase> delete ‘t1’, ‘r1’
  • delete all the rows hbase> truncate ‘’

Upvotes: 2

Related Questions