Oracle unique indexes, UNIQUE constraints, links between primary keys

Source: Internet
Author: User
Tags one table table definition

A primary key (primary key) is one or more fields in a table whose values are used to uniquely identify a record in a table, and in a relationship of two tables, the primary key is used to refer to a specific record in one table from another table, a unique keyword when a primary key is part of a table definition. A table's primary key can consist of multiple keywords, and the primary key column cannot contain null values. Depending on the attribute of the primary key: null values cannot exist and the values must be unique, so when not NULL and unique constraints are added to a field in Oracle for a table that does not have a primary key, the field defaults to the table's primary key.

Creates two tables with the same table structure, test_1 specifies C1 as the primary key, Test_2 adds not NULL and unique constraints to C1, and does not specify a primary key.

To view test_2 keys

To view test_1 keys

A unique index that does not allow rows with the same index value, thereby prohibiting duplicate indexes or key values. When the index is created, the system checks for duplicate key values and checks each time the INSERT or UPDATE statement is used to add data.

Create a test_5 table and add a unique index to C1.

View the index on the test_5.

View the constraints on the test_5.

The unique constraint guarantees that the data in a field or set of fields is unique compared to the data of other rows in the table. A unique constraint is created in Oracle and a unique index is generated accordingly.

Create a table test_6 and add a unique constraint to the C1 column.
Http://i2.51cto.com/images/blog/201801/30/b530bbab7577cf7ef8c8ce4c47e42117.png?x-oss-process=image/watermark, size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk= "alt=" Oracle unique index, UNIQUE constraint, contact between primary keys "/>

View the constraints on the test_6.

View the index on the test_6.

Oracle unique indexes, UNIQUE constraints, links between primary keys

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.