Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the problem of ORA-00955 when ORACLE modifies the primary key

Shulou Source: shulou.com Published: 2022-06-02 05:25:12 10月02日 Update

This article introduces the relevant knowledge of "how to solve the problem of ORA-00955 when ORACLE modifies the primary key". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The solution to the occurrence of ORA-00955 when ORACLE modifies the primary key

ORA-00955: the name is already used by an existing object

Oracle creates a compound primary key

Take the drug_stock table of the pharmacy as an example, you need to add a field to the primary key: PUTINSTORAGE_DATE

The original primary key name: PK_DRUG_STOCK, the key values are: DRUG_CODE, DRUG_SPEC, FIRM_ID, PACKAGE_SPEC, BATCH_NO, STORAGE

Modified primary key name: PK_DRUG_STOCK, key values: DRUG_CODE, DRUG_SPEC, FIRM_ID, PACKAGE_SPEC, BATCH_NO, STORAGE, PUTINSTORAGE_DATE

-- delete the primary key

ALTER TABLE PHARMACY.DRUG_STOCK DROP PK_DRUG_STOCK

-- Delete primary key index

Drop index PHARMACY.DRUG_STOCK_I_2

Drop index PHARMACY.DRUG_STOCK_I_3

-- add compound primary key

-- Create/Recreate primary, unique and foreign key constraints

Alter table PHARMACY.DRUG_STOCK

Add constraint PK_DRUG_STOCK primary key (DRUG_CODE, DRUG_SPEC, FIRM_ID, PACKAGE_SPEC, BATCH_NO, STORAGE, PUTINSTORAGE_DATE)

Using index

Tablespace TSP_PHARMACY

Pctfree 10

Initrans 2

Maxtrans 255

Storage

(

Initial 2M

Next 1M

Minextents 1

Maxextents unlimited

);

-create an index

-- Create/Recreate indexes

Create index PHARMACY.DRUG_STOCK_I_2 on PHARMACY.DRUG_STOCK (DRUG_CODE, DRUG_SPEC)

Tablespace TSP_PHARMACY

Pctfree 10

Initrans 2

Maxtrans 255

Storage

(

Initial 640K

Next 1M

Minextents 1

Maxextents unlimited

);

Create index PHARMACY.DRUG_STOCK_I_3 on PHARMACY.DRUG_STOCK (STORAGE)

Tablespace TSP_PHARMACY

Pctfree 10

Initrans 2

Maxtrans 255

Storage

(

Initial 64K

Next 1M

Minextents 1

Maxextents unlimited

);

This is the end of the content of "how to solve the problem of ORA-00955 when ORACLE modifies the primary key". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Time out problem content more knowledge index practicality achievement next name dilemma field actual object situation article method case ribbon website Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Docker Apple Microsoft Linux