Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Empower Replay: Limited Edition
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
      • About the DevOps Program
      • DataMiner DevOps Support
  • Downloads
  • More
    • DataMiner Releases & Updates
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

reset autoincrement value back to 1 in a table

490 views9th May 2025element removal protocol.DeleteRow
1
peng fei158 27th November 2024 1 Comment

Hi

I have a table using autoincrement in column 1 (primary key).

And i have a button to reload the table. The button deletes all the rows from the table and Re-add them into the same table.

i use protocol.NotifyProtocol(156 /*Delete row*/, tableID, Pkey) to delete the rows from the table.

Then i use protocol.NotifyProtocol(149 /*Add new row*/, tableID, null) to re-add and use SetParameterIndex to fill the cell of the row.

The delete row and re-add row works all fine.

However, the only problem i have is:

seems the primary key (autoincrement) somehow didn’t get reset to 1 when i delete all the rows from the table. When i re-add the rows in, the primary key value increase from the last deleted value.

e.g.,

I added 4 rows. the autoincrement primary key will be:

1,

2,

3,

4,

Then I reloaded the table, all 4 rows were deleted from the table. And the 4 rows were re-added into the same table. But the primary key start from 5.

5,

6,

7,

8

How can i reset the autoincrement primary key back to 1 when i delete all the rows from the table?

Thanks

Marieke Goethals [SLC] [DevOps Catalyst] Posted new comment 9th May 2025
Marieke Goethals [SLC] [DevOps Catalyst] commented 9th May 2025

Hi,
I see that this question has been inactive for some time. Do you still need help with this? If not, could you select the answer that has been most helpful for you (using the ✓ icon)?

2 Answers

  • Active
  • Voted
  • Newest
  • Oldest
1
Laurens Moutton [SLC] [DevOps Enabler]8.84K Posted 27th November 2024 0 Comments

Hi,

I did not test this, but it might be possible when all the rows are removed and when then restarting the element that the primary key will start again from 1.

Do note that an auto increment primary key is just something that is used as a unique identifier when there are no other identifiers possible. Meaning if the primary keys are re-used that they could be linked to past unrelated data.
In other words, if there is a column that has trending active on a row and the table gets cleaned up and the primary key restarts, that when a new row is added to this same key this means when requesting the trend graph will show the old data and the new data. Other items, like the AI prediction, also rely on the primary key identifier and could be making wrong predictions because the data is not related to each other.

Regards,

Laurens Moutton [SLC] [DevOps Enabler] Answered question 27th November 2024
0
José Silva [SLC] [DevOps Catalyst]1.43K Posted 27th December 2024 0 Comments

Hi,

If Laurens’ suggestion doesn’t resolve the issue, you can consider implementing a custom auto-increment mechanism to achieve your desired behavior.

When adding rows to the table, you can track the current counter and increment it by 1 for each new row.

To determine the current count, you could:

1. Retrieve all primary keys from the table and calculate the count dynamically, or
2. Store the counter in a hidden parameter and update it as needed.

When deleting all rows from the table, ensure you reset the counter to zero so it starts fresh when re-adding rows.

I hope this helps!

José Silva [SLC] [DevOps Catalyst] Answered question 27th December 2024
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs