24
Views
5
Comments
Solved
is there any shortcut to clear table data?
Question

Hi, 

I want to know is there any way to clear table data, i'm using sql delete query but it's not working. I'm creating creating test button and run every time.

2025-05-02 20-28-47
Drishti Menghani
Solution

Hi, 

Well it's not that clear but I'm assuming you are having entity and want to clear the data.

You mentioned SQL delete is not working

Possibility:

1. Parent child relation is preventing that, like ex: there's record in child entity which is protected and you are deleting. Make sure to delete child entitiy first.

2. You might be using just the test sql feature, which will not delete anything nor add, it's just to test the SQL syntax.

Solution instead of test button:

1. Can call that using timer, whenever you need.

2. Also in sql after query syntax you can try something, Exec('com'+'mit'), which might end up running the query. I think Outsytesm no longer support this but can give it a try.

3. You can also use a forge component SQL Sandbox to execute queries.

Hope this will help!!

UserImage.jpg
Raghav Rai

thank you drishti, second solution works for me, there was error but deleted the data.


2026-01-28 16-57-48
Mihai Melencu
Champion

Hi @Raghav Rai ,

You don't need to use the SQL Delete directly on the button. Instead, create a Server Action in the module where your entities are defined. Inside that action, add a SQL node with the following query: 

DELETE FROM {EntityName}

Also, make sure in your Output Entities / Structures you add the same entity.

Next step is to add a timer for that action and set it to run When Published.

Then publish the module, the timer will be triggered after you publish the module.

If this doesn't delete your records then check the Service Center for errors.


UserImage.jpg
Raghav Rai

thank you mihai for respond

2023-07-21 10-31-07
Neelesh Gupta

Hi @Raghav Rai we can delete record from SQL (Delete) but it will not work as expected always, especially if there are referential integrity constraints or any issue in query then it will inconsistent.

so you can use a server action with a For Each Loop:

  • Create a Server Action (for example, Delete_All).
  • Fetch all records from the entity using an Aggregate (e.g., GetAllRecords).
  • Use a For Each loop to iterate through each record and call the entity's Delete action for each record’s Id.
  • After deleting, use Refresh Data to update the table on the UI if needed
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.