Primary Key and unique constraint of 14-SQLite, primary key of 14-sqlite

Source: Internet
Author: User

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

Related Article

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.