Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
5 replies
Subscribers
7 subscribers
Views
2817 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Hello, Normally, we create databases from CDTs and Datastores, and using au
Adel Ammari
over 9 years ago
Hello,
Normally, we create databases from CDTs and Datastores, and using auto generation for primary keys.
After using whichever application we develop which saves on that table, the primary key count reaches a certain number per say 20. At some point, we would like to drop all data and start clean, resetting the primary key counter back to 1.
To overcome this, we tried dropping and recreating the sequences, which seems to work well, but not for long, after resetting the counter 1, and using the system for a couple of days, we find a sudden jump, causing a non consistent primary key counter. e.g.1.2.3.4 then 21 instead of 5.
Please advise what else needs to be done to fully reset the counter to 1 causing a clean consistent primary key count 1.2.3.4.5...etc.
OriginalPostID-150883
OriginalPostID-150883
Discussion posts and replies are publicly visible
0
Mohammad Abusinnah
Appian Employee
over 9 years ago
Did you check if the database if the database locks the used sequence? please check
stackoverflow.com/.../how-do-i-reset-a-sequence-in-oracle
for more information.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
narasimhaadityac
A Score Level 2
over 9 years ago
Hi Adela,
While creating a sequence we have an option to specify the Cache value.please find below if cache option is specified.
The downside of creating a sequence with a cache is that if a system failure occurs, all cached sequence values that have not be used, will be "lost". This results in a "gap" in the assigned sequence values. When the system comes back up, Oracle will cache new numbers from where it left off in the sequence, ignoring the so called "lost" sequence values.
Please refer for more info -
www.techonthenet.com/.../sequences.php
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Conor Cahill
Certified Lead Developer
over 9 years ago
What type of SQL are you using for your database? If you don't care about any of the data in the table, would it be possible to simple drop and recreate the entire table?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Sathya Srinivasan
Appian Employee
over 9 years ago
What you are describing is common in databases like ORACLE. So first thing would be to understand your database and how primary keys are managed. For e.g. in MySQL, its an out of the box database feature to manage auto increment on a primary key field - However, in Oracle, it is done by defining a sequence. Now, sequences have a different mechanism based on how you want to block sequencing. Oracle sequences have caching that blocks a set of numbers assuming an optimistic sequencing. So if another call comes in at around the time, the sequence number will jump by the cache size. Caches are meant for improving write efficiency in Oracle. You might want to look into this.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Adel Ammari
over 9 years ago
Thanks for your answers, i am on an oracle DB, however my question is that even when i drop and recreate the sequence, it does start to count correctly from 1 followed by 2...etc, but then at some point it jumps to 21. skipping many numbers. I assume this is due to the caching mentioned above. Is there no way around this?
Again, thanks a lot for all your answers.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel