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

The role of constraints in mysql

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

Share

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

Editor to share with you the role of constraints in mysql, I hope you will learn a lot after reading this article, let's discuss it together!

What is a constraint?

Constraint is a kind of "stipulation" that requires what conditions the data needs to meet.

There are mainly the following constraints:

Primary key constraint: form: primary key (field name)

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

Unique constraint: form: unique key (field name)

Meaning (function): make the value of the setting field "unique", which is naturally distinguishable.

Foreign key constraint: form: foreign key (field name) references other table names (corresponding to field names in other tables)

Meaning (function): make the value of the set field already have the value in the corresponding field in the corresponding table.

Non-null constraint: form: not null, which is actually the "not null" attribute that is written when setting a field.

This constraint can only be written on field properties

Default constraint: form: default XX value; in fact, it is the "default default" property written when setting a field.

This constraint can only be written on field properties

Check constraints: form: check (some kind of judgment statement), such as:

Create table tab1 (age tinyint,check (age > = 0 and age)

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