14-sqlite's primary KEY and UNIQUE constraint

Source: Internet
Author: User
Tags one table sqlite

First, PRIMARY key
uniquely identifies a single row ( only one primary key in a table )
The
primary key should be meaningless to the user ( commonly used for indexing )
never update the primary key , or violate the principle of no meaning to the user
the primary key should not contain dynamically changing data, such as timestamp, creation time column, modified time column, etc.
In a two-table relationship, the primary key is used to refer to a specific record in one table from another table
Syntax:
CREATE TABLE table name (column name 1 data type primary key, column name 2 data type, column name 3 data type, ...);

Second, the only constraint
used to guarantee that data in a column (or set of columns) is unique, similar to a primary key, but that a table with a primary key can contain multiple unique constraints, but only one primary key unique constraint column can be modified or updated
When you create a table, you set it by unique
Syntax:
CREATE TABLE table name (column name 1 data type unique, column name 2 data type,..。 );

Third, examples

14-sqlite's primary KEY and UNIQUE constraint

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.