Oracle primary key deletion, joint primary key creation, oracle primary key

Source: Internet
Author: User

Oracle primary key deletion, joint primary key creation, oracle primary key
1. Delete the primary key alter table tablename drop PRIMARY_KEY execute the preceding SQL statement to delete the primary key; if it fails, use ALTER TABLE TABLENAME DROP CONSTRAINTS COLUMN CASCADE; -- delete the constraint ALTER TABLE TABLENAME DISABLE PRIMARY_COLUMN; -- The column set as the primary key is invalid drop index INDEX_NAME; -- delete the primary key INDEX
2. view the primary key constraint SELECT * FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'p' AND TABLE_NAME = 'name of the table you want to view 'and owner = USER
3. Create the joint primary key alter table add constraints 'constraint name' primary key (COLUMN, COLUMN ,...);
Oracle joint primary key Creation

Alter table xxx add constraints xxx_pk primary key (c1, c2, c3, c4, c5 ....);

Oracle uses an SQL script to delete the original primary key and then create a new primary key. The new primary key is added based on the original primary key.

Delete an existing primary key first:
Alter table devuser. tb_term_info drop primary key;
Add another field:
Alter table devuser. tb_term_info add column attr_fg;
Re-create a primary key:
Alter table devuser. tb_term_info
Add primary key (time, numer_sq, system_id, system_type_id, attr_fg)
Using users
Tablespace IDX_TS_BUSIS_ONLINE
Pctfree 10
Initrans 2
Maxtrans 255
Storage
(
Initial 64 K
Minextents 1
Maxextents unlimited
);
Note that you must have the corresponding operation permissions on the devuser User table.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.