Home > database >  A great god for help! Existing large amounts of data sorting column (PK_ID) disconnect, how to conti
A great god for help! Existing large amounts of data sorting column (PK_ID) disconnect, how to conti

Time:10-19

CodePudding user response:

Use a sequence, or existing data maximum plus one,

CodePudding user response:

Don't know you is how to generate the PK_ID, even with sequence in oracle, if not to delete data can be any card ID is continuous, but when have data to delete, the sequence will be interrupted, and the deleted ID value, the sequence is not found also won't recycling use,
Calculation PK_ID if you are in your application, you can look up to the maximum ID value, then add 1, want to consider when concurrent ID repeat problem, need to lock table lock table affect database performance,
Recommend the use of sequence, the sequence of the initial value is equal to the existing maximum + 1, each time from 1-6

CodePudding user response:

Continue to sort of what you say is in accordance with the existing ids, the completion of the missing? It is not possible

CodePudding user response:

Sequence of the initial value is equal to the existing maximum + 1, since every time 1, how do you write this? Would the original data reorder?

CodePudding user response:

reference 4 floor dabao2266 response:
sequences of the initial value is equal to the existing maximum + 1, since increased 1 at a time, how do you write this? Would the original data reorder?

Oracle stored in the data is not in the order you insert in written to the file, even if you only do insert data, write data block is not in accordance with the order (you can test under, he create a simple table, then ID defines the primary key (primary key is indexed by default), then insert some data, query, query is not to add the order by, you see is not necessarily the order of the order you insert),
By what to sorting, data sorting, is controlled by your select statement to

The create sequence student_id
1-2 minvalue minimum
3 nomaxvalue - not setting the maximum (decision) by machine, or according to the value range set table field maxvalue
A maximum 999-4 maxvalue
5 start with 1 - from 1 began to count, numerical variable
6 increment by 1 - plus one at a time, the numerical variable
7 nocycle - has been accumulating, do not cycle; Cycle: after peak, will start from scratch accumulative
8 nocache; - do not build buffer, if establish a cache system will automatically read from the cache value a seq, it will accelerate the speed; If used in single cache, or oracle died, so the next time the seq value will not be coherent, so don't recommend to use the cache,

CodePudding user response:

In principle, the main key should not participate in any logic, but only as a unique identifier,

What effect do you want to achieve?
  • Related