755
Views
14
Comments
How to reset table ID ?
Application Type
Reactive

Hello,

Please how can i reset my table ID after have deleted all the records ?

I tried to delete the table but some errors appears due to the database relationship and the behavior still very weird so i don't think is a good solution.

Thanks

Julien

2021-06-02 20-50-04
Márcio Carvalho

Your problem is on the ID, where don't let you delete the table? if so, you must change the delete rule of the property's property ID to ignore(if you want to keep the data) or delete(if you want to remove).

Can you give more details?

Regards,

Márcio C.

UserImage.jpg
Julien Garcia

I can delete the table BUT i can't reset the ID increment to zero.

2021-06-02 20-50-04
Márcio Carvalho

Try this, I dunno if it will work but I already saw it in some cases. Try to change the name of the ID and publish, and then put again as ID and publish again and tell me if the ID is at zero now.


The table you are using as references to other tables?

2026-01-23 18-47-37
Carlos Ioliva

Hi,

If your user have permissions, you can use a TRUNCATE statement.

TRUNCATE TABLE {EntityName};

UserImage.jpg
Julien Garcia

Hi,

I tried with SQL test but it not works. Error :

Thanks

2021-04-17 09-53-48
José Gonçalves

Hi Julien,

you'll probably have to do this directly on SQL Server.

2021-05-21 10-29-16
Abdus

Please check the delete rule property of entity, then fire Truncate command in SQL.

2021-05-18 02-27-17
Manish Gupta
Champion

Hello Julian 

To delete the data from Entity... first look into the Entity Delete Rule and it should be Ignore (If you want to delete the data anyhow and "Ignore" will keep the relative data in other tables.)


Then try to delete the rows or use  TRUNCATE TABLE {EntityName}; direct in SQL


This might work for you :)

2024-03-14 14-46-22
Nelson Inácio

Hi @Julien Garcia,

To reset a table primary key auto number you need to truncate the table.

SQL Server - https://docs.microsoft.com/en-us/sql/t-sql/statements/truncate-table-transact-sql?view=sql-server-ver15

Oracle - https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10007.htm#SQLRF01707

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Guys, the table trunc only works on on-premise with enough permissions. In OutSystems hosted cloud environments you will never have sufficient database permissions to do this.

One option you have is to cut paste the entity in your module. This will generate a new table in the database.

With a search on the forum you would have find this answer probably multiple times.

2024-01-31 05-29-41
Akshay Deshpande

Hello julien, 

if above any thing is not working than you direct cut and paste the your Entity(which you want to nullify). So it is automatically truncate the data and you will see the id start from zero.


thanks,

AKshay Deshpande.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

"if above any thing is not working" then your suggestion is also not working, as I already suggested it 3 days ago. :)

2024-01-31 05-29-41
Akshay Deshpande
2024-04-17 08-38-56
Dhineshkumar K

HI, 

If you cut and paste the entity the data will cleared and the ID will start from 1.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.