SQL Anywhere autoincrement reset
-
06-09-2019 - |
Question
I've got a SQL Anywhere 9 database, and I would like to reset the autoincrement value on one of my columns to a specific number.
I guess I need the SQL-Anywhere equivalent of:
ALTER TABLE foo AUTO_INCREMENT =100
Solution
Just so the answer is actually here, not just linked to:
Use the sa_reset_identity
system procedure:
sa_reset_identity (
[ table_name
[, owner
[, new_identity_value ] ] ]
)
OTHER TIPS
A google search turned up this. I have never used SQL Anywhere, so I'm afraid I can't help anymore.
The correct system procedure is sa_reset_identity
CALL sa_reset_identity('table_name', 'user_name', new_start_value -1);
For example, you have a table called CITIES, a user DBA and you want the autoincrement to start with value 1. Your code would be:
CALL sa_reset_identity('cities', 'DBA', 0);
Source: http://www.sqlines.com/sybase-asa/autoincrement_identity
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow