How do I delete all data in a Cassandra column family?

后端 未结 6 917
长发绾君心
长发绾君心 2020-12-25 09:46

I\'m looking for a way to delete all of the rows from a given column family in cassandra.

This is the equivalent of TRUNCATE TABLE in SQL.

6条回答
  •  滥情空心
    2020-12-25 10:32

    if you are working on cluster setup, truncate can only be used when all the nodes of the cluster are UP.

    By using truncate, we will miss the data(we are not sure with the importance of the data)

    So the very safe way as well a trick to delete data is to use COPY command,

    1) backup data using copy cassandra cmd
    copy tablename to 'path'

    2) duplicate the file using linux cp cmd
    cp 'src path' 'dst path'

    3) edit duplicate file in dst path, delete all lines expect first line.
    save the file.

    4) use copy cassandra cmd to import
    copy tablename from 'dst path'

提交回复
热议问题