How to delete/reset Historian?

I do not need the old data, just need to reset the tables.

I messed up deleting sqlt_data tables after setting the pruning options. Now it will only create a table called sqlth_1_data and no data can be forwarded to it.

Is there a way to just reset the historian?

I had tried disabling the Datasource History Provider, changing the Partition Length and Prune Age Units, stopping and starting the gateway, then enabling the Datasource History Provider, but that did not work.

Just now I again, disabled the Datasource History Provider, but this time rebooted the server, then enabled the Datasource History Provider and now it seems to be working.

I'd still like to know if there is a way to reset all the Historian tables and start from scratch? To get rid of any logged data and retired tags and so on.

If you don't care about the data simply delete all of the tag historian tables (sqlth_*)
The historian module is smart enough to recreate the tables.

Here is the user manual page explaining the the different tables and references.

When you say you deleted data tables after setting the pruning options. Do you mean Ignition pruned the older tables or you manually deleted them?

An automatic prune by Ignition shouldn't cause this issue. A manual deletion can cause issues.

When you delete the data table you must also remove the reference in the sqlth_partitions table.

My recommendation is to avoid manual edits to the historian tables. Let Ignition handle that stuff for you.

1 Like

I had set it to prune after 5 minutes and a partition size of 5 minutes. So after it created the new table, I expected it to delete the other tables. I guess I didn't wait long enough maybe. I had also removed them from the partition table but it just made the one new data table and couldn't put any data in it. Until I did as I described above.

I did find another thread where folks were describing this and they just set the pruning really low to get rid of the old Data tables that they didn't want but then you still can have issues with tags that you renamed or moved or whatever that have or have not been retired etc. I was wondering if there was a way to just reset everything?

The partitions will only be pruned when the newest data inside is older than the prune age.
It would be uncommon to want to remove all data and reset the historian so I don't know of any built in ways to do this.
If you delete all of the sqlth tables and reset the historian module they will be rebuilt. Including the sqlth_te (tags) table.

In Dev and local historization you can do this:

  • Disconnect the DB connection
  • Delete all the tables on the DB sql*, or if your scheme is historian only, delete the entire schema and re-create it
  • Disable the tag provider(s) using historization
  • Reset the Ignition Historian Module
  • Reconnect the DB
  • Enable the tag provider(s) using historization

Happy historization :tada:

1 Like