Unique and index in Oracle 10 GB

Source: Internet
Author: User

Unique and index in Oracle 10 GB

Unique and index in Oracle 10 GB

Create table test

(

X integer,

Y integer,

Z integer

);

Alter table test add constraint primary key (x); -- generates a constraint and an index of the same name.

Create unique index index01 on test (x, y );

-- Create unique index index02 on test (x, y); -- identical indexes are not allowed, even if the index names are different.

Create unique index index03 on test (y, z );

Create unique index index04 on test (z, y); -- index04 is an index different from index03

Alter table test add constraint cons01 unique (x, y, z); -- generates a constraint and automatically generates a UNIQUE index named cons01

Alter table test add constraint cons01 unique (x, y

Alter table test add constraint cons01 unique (y, x); -- generates a constraint, but because it is the same as index01, indexes cannot be automatically generated.

-- Create unique index cons01 on test (x, y); -- cannot be executed because the index cons01 has been bound to the index automatically created by cons01

Alter table test add constraint cons012 check (x> 100 );
Alter table test add constraint cons013 check (x> 100); -- check can have the same content

Solution:

Extract all constraints (UCPR)

Extract all indexes whose names are not in the restricted 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.