Oracle has five constraints. Primary key primary keys constraints, foreign key foreign constraints. Unique constraint, not null constraint, and check constraint. Remember: constraints are for a column.
Check constraints: alter table temp add constraint ck_temp_age CHECK
(AGE> 0) AND (AGE <= 125); in this way, age can only belong to the range from 0 to 125. Other data cannot be inserted.
Next, let's explain the differences between the primary keys constraint and the Unique constraint:
The primary keys constraint must be greater than the Unique constraint, that is, the Unique constraint is available, and the primary keys constraint is available. In addition, the primary keys constraint requires that the field cannot be null. The primary keys constraint automatically adds a unique index to the field.
A unique index is a type of index.
Oracle index types: There are three classification methods:
First: by type: 1. B-tree index 2. Bitmap Index
Type 2: 1. Unique index 2. Primary keyword index 3. General Index (mainly used to increase the query speed)
Category 3: 1. Single Column index 2. Multi-column index 3. Function Index
Create index I _ename on emp (ename); then a general index is created.
Create bitmap index index_name ON normal_index_creation_clause; a bitmap index is created.
Create unique index dept_unique_idx on dept (dept_no) tablespace idx_1; then create a unique index
Create constraints-related indexes. You can use the using index statement to create indexes related to the unique and primary key constraints. For example:
Alter table table_name
Add constraint PK_primary_keyname primary key (field_name)
Using index tablespace tablespace_name;
The last one used a lot to create constraints-related indexes.