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

What are the navicat table constraints

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

Share

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

This article mainly introduces what the navicat table constraints are, the article is very detailed, has a certain reference value, interested friends must read it!

There are several kinds of constraints in the database

● primary key constraint (Primary Key constraint): requires that the primary key column data is unique and is not allowed to be empty.

● unique constraint (Unique constraint): the column is required to be unique, allowed to be empty, but only one null value can occur.

● check constraint (Check constraint): a column value range limit, format restriction, etc., such as age, mailbox (must have @) constraints.

● default constraint (Default constraint): the default value of a column, such as a data item with many duplicates in the database, can be set to the default value.

● foreign key constraint (Foreign Key constraint): used to establish a relationship between two tables by specifying which column of the main table is referenced.

Recommended tutorial: MySQL getting started Video tutorial

Next we will introduce you to the process of creating foreign key constraints.

First of all, let's introduce the basic situation. Now that there are two tables, one is the teacher table and the other is the dept table. Now I want to set the dept property in the teacher table to the foreign key and associate the code property in the dept table. The specific situation is shown in the picture; all right, the basic situation is over, and now I will teach you how to set foreign keys in navicat for mysql.

1. Open my navicat, then find my teacher table, select it, and click 'design table'' on the menu bar.

2. Find "Foreign Keys" in the pop-up dialog box, and then stand alone.

3. Then there will be an interface for setting foreign keys, with a total of seven columns. Briefly introduce the meaning of these columns.

Name': can be left unfilled, and the system will be generated automatically if you save it later.

FieldName': is which key you want to set as a foreign key. Choose 'dept'' here

'The database associated with the Reference DadaBase': foreign key.

Reference Table': the associated table here is the dept table

'The field associated with Forgin filed Names':. Here is code.

'ondelete': is the action you choose when deleting. My choice here is setNull, which means that when the associated table is deleted, the teacher "dept field is set to null.

Onupdate': is the action you choose when you update. My choice here is CASCADE, which means that when the associated table is updated, the teacher "dept field is set to cascading updates.

4. Click 'save' to save and exit' after setting up, or click 'add Foreign Key' to add a foreign key.

The above is all the content of the article "what are the navicat constraints?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow 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