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.