Sequence alternate [message #687525] |
Tue, 28 March 2023 08:54  |
 |
deepakdot
Messages: 89 Registered: July 2015
|
Member |
|
|
Hi
I have a scenario. we have two Data Center with active-Passive. First six month DC1 will be active and next six month DC2 will be active. we have sequences for table. As we are using both the DC , to eliminate duplicate values from sequence, we use lets say even/odd number as below. So that when we switch to other DC, we don't get a duplicate values.
DC1 : 1,3,5,7,..
DC2 : 2,4,6,8,...
Question: Now we have a requirement that we can not skip any number, table should have values as 1,2,3,4 .. Is there any solution / idea to address this. we need to have unique numbers across both the data center. we can not have identity column on the table. Please suggest.
cheers,
Deepak
|
|
|
|
Re: Sequence alternate [message #687528 is a reply to message #687526] |
Tue, 28 March 2023 15:39   |
Solomon Yakobson
Messages: 3244 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
Quote:Question: Now we have a requirement that we can not skip any number
Not possible in general - user can get value from the sequence but then rollback transaction. If sequence has cache then each time database is restarted (say for maintenance or it chashes) unused portion of cached out sequence numbers is lost.
SY.
|
|
|
Re: Sequence alternate [message #687530 is a reply to message #687528] |
Tue, 28 March 2023 23:11   |
 |
mathguy
Messages: 77 Registered: January 2023
|
Member |
|
|
What are you using the sequence values for? (And, do you mean "sequence" in the sense of Oracle-provided sequences?)
In general, a sequence would be used to generate an artificial (but very useful!) primary key to a table. The same sequence may be used for more than one table, although I don't think it can be shared between different "data centers". I confess I have no idea what a "data center" is! Wikipedia is of no help - it says a "data center" is a building, a dedicated space within a building, or a group of buildings, used to house computer systems; that is what I thought, too, but I don't see what that would have to do with what you explained.
Anyway - if a "sequence" (in the technical sense as defined by Oracle) is used to generate values for an artificial primary key, then requiring that all the values be consecutive - without gaps - is just plain meaningless; anyone asking for such a thing has no business asking for it, since they have no clue what they are talking about. The values themselves aren't supposed to have any kind of real-life meaning; so why does it matter if there are gaps? This is a very common and very basic misconception, shared largely among incompetent managers who don't understand computing.
So - I'm confused. Can you please explain what a "data center" is in your terminology? What is a "sequence", and what it is used for? And how "data centers" are "sharing" a "sequence"?
|
|
|
|
|
|
|
|
Re: Sequence alternate [message #687536 is a reply to message #687535] |
Wed, 29 March 2023 07:49  |
 |
Michel Cadot
Messages: 68500 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
To address your downtime issue then:
Quote:You should use Oracle editions, with no downtime at all.
To address the no gap sequence then you have to use some lock or counter solution: table lock, row lock on counter, dbms_lock, or any other known solution as the one Barbara's link shows.
[Updated on: Wed, 29 March 2023 07:52] Report message to a moderator
|
|
|