Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]: Right Click on Table - Generate TRUNCATE statement #542

Open
millerjp opened this issue Nov 3, 2024 · 0 comments
Open

[feat]: Right Click on Table - Generate TRUNCATE statement #542

millerjp opened this issue Nov 3, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request right click

Comments

@millerjp
Copy link
Contributor

millerjp commented Nov 3, 2024

Do after #539

To truncate a table in Apache Cassandra, you use the TRUNCATE command. This command removes all data from the specified table immediately and irreversibly, as well as any materialized views derived from that table.

Requirements

Users right click on a table, select the truncate table option, we generate the CQL, users validates it and then we run it and then we execute the command against the table.

Important difference is to use CONSISTENCY ALL; - include this statment in the generated CQL.

Before executing the TRUNCATE display a warning dialog saying


Warning: Truncate Operation

This operation is irreversible and will permanently delete all data in the table.

  • By executing this command, all rows in the specified table will be removed immediately.
  • Materialized views derived from this table will also be truncated.
  • Snapshots: If your Cassandra cluster is configured to take snapshots before truncation, a snapshot of the table's current data will be created for recovery purposes. Remember to remove this snapshot if they are not needed.
    • Clean up snapshots: Use nodetool clearsnapshot to remove snapshots if they are no longer needed.
    • Disable automatic snapshots: Modify cassandra.yaml to disable snapshots if you do not want this behavior.

Please confirm that you want to proceed with this operation, understanding its irreversible nature and potential impact on snapshots.


Syntax

The syntax for the TRUNCATE command in Cassandra is:

TRUNCATE [ TABLE ] [<keyspace_name>.]<table_name>;
  • keyspace_name is optional if the table is in the current keyspace.
  • table_name is the name of the table you want to truncate.

Examples

Here are some examples of how to use the TRUNCATE command:

-- Truncate a table in the current keyspace
TRUNCATE users;

-- Truncate a table in a specific keyspace
TRUNCATE keyspace_name.users;

-- Truncate a table with the optional TABLE keyword
TRUNCATE TABLE products;
@millerjp millerjp added enhancement New feature or request Needs Triage bugs which are not yet confirmed labels Nov 3, 2024
@millerjp millerjp self-assigned this Nov 3, 2024
@millerjp millerjp added this to the v1.1.0-release milestone Nov 3, 2024
@millerjp millerjp added right click and removed Needs Triage bugs which are not yet confirmed labels Nov 3, 2024
@millerjp millerjp assigned mhmdkrmabd and unassigned millerjp Nov 3, 2024
@millerjp millerjp changed the title [feat]: Right Click on Table - TRUNCATE table [feat]: Right Click on Table - Generate TRUNCATE statement Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request right click
Projects
None yet
Development

No branches or pull requests

2 participants