Learn what constraints are in PHP in one minute? There are mainly the following types of constraints?

慕斯
Release: 2023-03-10 22:08:02
Original
1352 people have browsed it

We have learned so much about PHP in PHP. I don’t know how much you know about constraints. I believe that a large number of people will not know this part of the knowledge. So don’t worry, this article will lead you to a more profound understanding. to learn about this content.

Related recommendations:What is the enum type in PHP? set type?

Constraints

What are constraints?

Yuedong is to ask what the data needs to meet A kind of "regulation" of conditions

There are mainly the following types of covenants:

Primary key covenants: Format: primarykey(field name);

Meaning (function), so that the value of this setting field can be used to "uniquely determine a row of data", which actually means "primary key".

Unique key form,unique key(field name);

Meaning (function) 1 Make the value of the set field "unique", naturally it is also distinguishable.

Foreign key constraints, form:

foreign key(字段名) references
Copy after login

Other table names (corresponding to field names in other tables);

Meaning (function): use The value of this set field must already exist in the corresponding field in the corresponding table specified by the other party.

Non-null constraint, in the form:

not null,
Copy after login

In fact, it is the "not nul!" attribute written when setting a field.

Default constraints: Form:

default XX 值:
Copy after login

In fact, it is the "default default value" attribute written when setting a field

In fact, Feng key About East, unique constraints and foreign key constraints are just "two different ways of saying the same thing". They are also called "primary key index", "unique index" and "foreign key index".

Check the East: Format:

check (某种判断语句),
Copy after login

For example,

create table tab1 ( age tinyint, check (age>=0 andage <100) /* 这就是检查约束*/ 
        
Copy after login

Related learning video sharing:php video tutorial

The above is the detailed content of Learn what constraints are in PHP in one minute? There are mainly the following types of constraints?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!