Primary Key and unique constraint of 14-SQLite, primary key of 14-sqlite
I. Primary Key
Uniquely identifies a row (one table can only have one primary key)
Primary keys should be meaningless to users (often used for indexing)
Never update the primary key, otherwise it violates the principle of no significance to users
Primary keys should not contain dynamically changed data, such as timestamps, creation time columns, and modification time columns.
In the relationship between two tables, the primary keyword is used to reference a specific record from another table in one table.
Syntax:
Create table Name (column name 1 data type primary key, column name 2 data type, column name 3 data type ,...);
Ii. unique constraints
Used to ensure that data in a column (or a group of columns) is unique, similar to a primary key, but different from a primary key
A table can contain multiple unique constraints, but only one primary key is allowed.The unique constraint column can be modified or updated.
When creating a table, use unique to set
Syntax:
Create table Name (column name 1 Data Type unique, column name 2 data type ,...);
Iii. Instances