Oracle constraints and Indexes

Source: Internet
Author: User
Constraints -------------------------------------------------------- constraints include: notnull, unique, primarykey, foreignkey, check

Constraints -------------------------------------------------------- constraints include: not null, unique, primary key, foreign key, check

Constraints
--------------------------------------------------------
Constraints include:
Not null, unique, primary key, foreign key, check
Not null (not empty)
If not null is defined in a column, data must be provided to the column when data is inserted.
Unique (unique)
When a unique constraint is defined, the column values cannot be repeated, but can be null.
Primary key (primary key)
It is used to uniquely represent the data of rows in the table. When the primary key constraint is defined, this column cannot be repeated and cannot be null.
Note: A table can have only one primary key at most, but multiple unqiue constraints are allowed.
===================== Index
----------------------------------------------------------
Single Column Index
Create index name on table name (column name)

Composite Index
Create index name on table name (column name 1, column name 2 );
Create index name on table name (column name 2, column name 1 );
SQL scans are performed from the back to the back, so the most excluded data is placed behind

Indexing principles:
1. Creating an index on a large table makes sense.
2. Create an index in the where clause or on a column frequently referenced in the connection Condition
3. The index level should not exceed Layer 4.

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.