Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report