Home > Database > Mysql Tutorial > body text

What is the role of identity column in sql

清浅
Release: 2020-09-15 17:29:32
Original
4439 people have browsed it

The identification column in SQL is also called an auto-increment column. Its function is to allow the computer to automatically generate the identification field value (sequence value) for the records in the table as required without manually inserting the value; the column values ​​are not repeated. , has the function of identifying each row in the table, and each table can only have one identifying column.

What is the role of identity column in sql

The definition and characteristics of the identification column

The identification column in SQL Server is also called the identifier column. It is customary to Also called self-increasing column.

This type of column has the following three characteristics:

1. The data type of the column is a numerical type without decimals

2. When performing an insert operation , the value of this column is generated by the system according to certain rules, and no null value is allowed

3. The column value is not repeated and has the function of identifying each row in the table. Each table can only have one identification column.

Due to the above characteristics, identification columns are widely used in database design.

The composition and function of the identification column

To create an identification column, you usually need to specify three contents:

1. Type (type )

In SQL Server 2000, the identity column type must be a numeric type, as follows:

decimal, int, numeric, smallint, bigint, tinyint

where It should be noted that when selecting decimal and numeric, the number of decimal places must be zero

In addition, pay attention to the numerical range of all representations of each data type

2, seed ( seed)

is the value assigned to the first row in the table, the default is 1

3, increment (increment)

The increment between two adjacent identification values. The default is 1.

The identification column allows the computer to automatically generate the value of the identification field for the records in the table as required.

The above is the detailed content of What is the role of identity column in sql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
sql
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template