Rajasubramanian SM
Rajasubramanian SM

Reputation: 23

Where to set Maximum Id of Primary Key in Oracle SQL Developer?

Where to set Maximum Id of Primary Key in Oracle SQL Developer? I have seeded some data Production DB to Lower Environment. But In production Maximum ID is more than million. So I want set Million as the Current maximum ID of the Primary Key in one of the Lower Environment table. Now it is failing with Maximum ID is already existing.

I have seeded some data Production DB to Lower Environment. But In production Maximum ID is more than million. So I want set Million as the Current maximum ID of the Primary Key in one of the Lower Environment table. Now it is failing with Maximum ID is already existing.

Upvotes: 0

Views: 116

Answers (1)

Littlefoot
Littlefoot

Reputation: 142993

Nowhere, as far as I can tell. It is you who should pay attention to what you're inserting into target environment, either

  • when "exporting" data from production, or
  • when "importing" data into lower environment (whatever that means)

You didn't explain how you did that - if you used select statement to create a CSV file, you'd e.g.

select ...
from production_Table
where id <= 1e6         -- restrict IDs to at most 1 million

or - while inserting data into the target - do

insert into lower_environment_table
select ... from ...
where id <= 1e6

It would be even easier if databases are in the same network so that you could create a database link and directly copy data from one environment to another.

If you used Data Pump export and import utilities, you could apply the where clause so that .dmp file already contains rows you want which would then simplifiy import.

On the other hand, if you don't care about possible duplicates (which are prevented by primary key constraint anyway, as it won't allow them), insert would simply fail and you'd ignore all those errors.

Basically, the final "answer" depends on the way you're performing that process.

Upvotes: 1

Related Questions