# How to reset the auto\_increment vlaue of a column whenever we truncate table

**URL:** <https://www.singlestore.com/forum/t/how-to-reset-the-auto-increment-vlaue-of-a-column-whenever-we-truncate-table/1899>\
**Category:** Procedural SQL\
**Created:** [April 30, 2020, 3:08am UTC](https://www.singlestore.com/forum/t/how-to-reset-the-auto-increment-vlaue-of-a-column-whenever-we-truncate-table/1899 "2020-04-30T03:08:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjsv](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@rjsv](https://www.singlestore.com/forum/u/rjsv)\
**Post date:** [April 30, 2020, 3:08am UTC](https://www.singlestore.com/forum/t/how-to-reset-the-auto-increment-vlaue-of-a-column-whenever-we-truncate-table/1899/1 "2020-04-30T03:08:31Z")

</div>

We have a table as below. While deleting the records,we will capture the records into this table. To generate the id value we are using ‘auto\_increment’ column. We will truncate this table weekly once. How to reset the auto\_increment values from the number 1 again whenever we truncated the table.(We don’t want to drop and recreate the table.)

CREATE TABLE IF NOT EXISTS endpoints\_audit  
(id int auto\_increment ,  
model varchar(100) not null,  
.  
.  
.  
.  
.  
.’  
created\_on timestamp default now(),  
KEY (`model`,`id`) USING CLUSTERED COLUMNSTORE  
)

---

<div class="post-metadata">

**Author:** ![hanson](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/hanson/32/196_2.png) [@hanson](https://www.singlestore.com/forum/u/hanson)\
**Post date:** [April 30, 2020, 10:59pm UTC](https://www.singlestore.com/forum/t/how-to-reset-the-auto-increment-vlaue-of-a-column-whenever-we-truncate-table/1899/2 "2020-04-30T22:59:35Z")

</div>

MemSQL doesn’t support a way to reset the auto\_increment values. Why don’t you want to drop the table and recreate it, given that you are deleting all the data anyway?

This post talks about how to create your own sequence generator using an auto\_increment on a reference table, but of course it is not fully general. It might work for some apps.

> **[Sequence Generator in MEMSQL](https://www.singlestore.com/forum/t/sequence-generator-in-memsql/397)**
>
> We are migrating from Netezza to MEMSQL. However, The sequence generator is integral part of Netezza and it is extensively used in my project. I dont see the corresponding equivalent in MEMSQL. Can someone please suggest How we can go ahead and...

---

<div class="post-metadata">

**Author:** ![ganesh.usi.gk](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/g/e19b73/32.png) [@ganesh.usi.gk](https://www.singlestore.com/forum/u/ganesh.usi.gk)\
**Post date:** [August 4, 2022, 6:06am UTC](https://www.singlestore.com/forum/t/how-to-reset-the-auto-increment-vlaue-of-a-column-whenever-we-truncate-table/1899/3 "2022-08-04T06:06:41Z")

</div>

Hi Team,

Any update on AUTO\_INCREMENT Value to reset features. I could not drop and recreate , i will have permission to truncate/delete the data.so i need to reset the value to 1 whenever i required.

Kindly update me if this is resolved

---

<div class="post-metadata">

**Author:** ![hanson](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/hanson/32/196_2.png) [@hanson](https://www.singlestore.com/forum/u/hanson)\
**Post date:** [August 5, 2022, 11:56pm UTC](https://www.singlestore.com/forum/t/how-to-reset-the-auto-increment-vlaue-of-a-column-whenever-we-truncate-table/1899/4 "2022-08-05T23:56:59Z")

</div>

We don’t support this. We have an open feature request for it. At some point I expect us to add sequences that could be reset and could be used to provide the next value for a table column. That would solve this problem for you. That’s the likely thing we’d do first.

You can adjust your next auto increment value but it must be higher than all the data and all the previously used values:

> **[AGGREGATOR SYNC AUTO\_INCREMENT · SingleStore Documentation](https://docs.singlestore.com/cloud/reference/sql-reference/data-manipulation-language-dml/aggregator-sync-auto-increment/)**
>
> SingleStore is a modern relational database for cloud and on-premises that delivers immediate insights for modern applications and analytical systems. Book a demo or trial today!

And I see that is not what you want.
