0

Can I update existing sequence values form staring with 1.

Example : In table one sequence column starting the sequence form 5001 but i want change that value form starting with 1.

If it is possible how can approach?

Alex Poole
  • 183,384
  • 11
  • 179
  • 318
Yellappa
  • 403
  • 1
  • 5
  • 16
  • Possible duplicate of [How to create id with AUTO\_INCREMENT on Oracle?](https://stackoverflow.com/questions/11296361/how-to-create-id-with-auto-increment-on-oracle) – Anthony Horne Jun 23 '17 at 07:10
  • Possible duplicate of [How do I reset a sequence in Oracle?](https://stackoverflow.com/questions/51470/how-do-i-reset-a-sequence-in-oracle) – trincot Jun 23 '17 at 07:24
  • How are you going to handle it when your sequence generates values you already have in the table (e.g. 5001)? Or do you mean you want to update all existing values in that column and this is nothing to do with [an Oracle sequence](http://docs.oracle.com/database/121/CNCPT/schemaob.htm#CNCPT88878)? (In which case... is the column a primary key? And if these are synthetic anyway why update?) – Alex Poole Jun 23 '17 at 09:03
  • I am using NuoDB database, The column contains duplicate sequence numbers already so i want to make it is non duplicates numbers.Finally i want to reset the whole sequence from starting with 1 in that column. – Yellappa Jun 23 '17 at 09:14
  • So why have you tagged your question with [oracle11g]? – Alex Poole Jun 23 '17 at 09:33
  • NuoDB is also using SQL only so based on that i have expected get any idea. – Yellappa Jun 23 '17 at 09:36

2 Answers2

0

I think your easiest path is to delete the table and reload. Before reloading specify a primary key. This will prevent duplicates getting inserted.

0

You can change the sequence starting value with ALTER SEQUENCE. However, setting the start point back causes conflicts with existing values in the table. Also NuoDB does not necessarily handout sequence numbers in sequence. Given that it's a distributed database, a sequential number generator would greatly affect performance as each TE would need to check some master for next sequence number. What NuoDB does is handout a sequence block which the TE uses and then request another block when it runs out. If the TE is shut down and restarted it will get a new block.