Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Can the phpmyadmin primary key be repeated?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the use of phpmyadmin primary key in detail for everyone. The sample code introduced in this article is very detailed. Zero basis can also refer to this article. Interested friends can refer to it.

phpmyadmin primary key can be repeated

The full name of a PRIMARY KEY is "PRIMARY KEY CONSTRAINT." A MySQL primary key constraint is a column or combination of columns whose value uniquely identifies each row in the table. Such a column or columns is called the table's primary key, which enforces the table's entity integrity.

A primary key constraint is an identifier that defines a primary key in a table to uniquely identify each row of data in the table.

A primary key can be a column in a table or a combination of columns, where a primary key composed of multiple columns is called a composite primary key.

Primary keys should obey the following rules:

Only one primary key can be defined per table.

The primary key value must uniquely identify each row in the table and cannot be NULL, that is, there cannot be two rows of data in the table with the same primary key value. This is the uniqueness principle.

A column name can appear only once in a composite primary key list.

Composite primary keys cannot contain unnecessary redundant columns. When a column of a composite primary key is deleted, if the primary key formed by the remaining columns still satisfies the uniqueness principle, then the composite primary key is incorrect. This is the principle of minimization.

Set primary key constraints when creating tables:

In the CREATE TABLE statement, the primary key is specified by the PRIMARY KEY keyword.

Specify the primary key at the same time as defining the column. The syntax rules are as follows:

PRIMARY KEY [default]

[Example 1] Create tb_emp 3 data table in test_db database. Its primary key is id. Enter SQL statement and run result as shown below.

mysql> CREATE TABLE tb_emp3 -> ( -> id INT(11) PRIMARY KEY, -> name VARCHAR(25), -> deptId INT(11), -> salary FLOAT -> );Query OK, 0 rows affected (0.37 sec)mysql> DESC tb_emp3;+--------+-------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+--------+-------------+------+-----+---------+-------+| id | int(11) | NO | PRI | NULL | || name | varchar(25) | YES | | NULL | || deptId | int(11) | YES | | NULL | || salary | float | YES | | NULL | |+--------+-------------+------+-----+---------+-------+4 rows in set (0.14 sec)

The above is the introduction to the use of phpmyadmin primary key, the detailed use of the situation also have to be used by everyone to know the specific essentials. If you want to read more articles related to content, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report