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

Oracle unique indexes, unique constraints, relationships between primary keys

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

A primary key (primary key) is one or more fields in a table whose values are used to uniquely identify a record in the table. In the relationship between two tables, the primary key is used to reference a specific record from another table in one table, a unique key, a part of the table definition. The primary key of a table can be composed of multiple keywords, and the primary key cannot contain null values. When a primary key is created in oracle, a unique index is automatically generated, and the unique index can be looked up in the user_indexes view.

Create 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 no primary key is specified.

View the index of test_1,test_2

View the constraints of test_1,test_2

A unique index that does not allow rows with the same index value, thus prohibiting duplicate indexes or key values. The system checks for duplicate key values when creating the index and each time you add data using an INSERT or UPDATE statement.

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

View the index on test_5.

View the constraints on the test_5.

Unique constraints guarantee that the data in a field or set of fields is unique compared to the data in other rows in the table. A unique constraint is created in oracle and a unique index is generated accordingly.

Create the table test_6 and add unique constraints to the C1 column.

View the constraints on the test_6.

View the index on test_6.

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

Database

Wechat

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

12
Report