Mysql foreign Key Usage considerations

Source: Internet
Author: User

Using foreign key in Mysql is not as simple as Oracle and access. The following describes the issues that should be paid attention to during use:

Step 1: Create a table
First, open the command line window, enter the Mysql bin directory, select the corresponding database, and create the T_USER table:

Create table t_user (id int (11) not null auto_increment primary key, name VARCHAR (20), group_id int (10) type = InnoDB;

Create a T_PASSPORT table:
Create table t_passport (id int (11) not null auto_increment primary key, serial VARCHAR (20) type = InnoDB;

Note: The description of InnoDB is as follows:

InnoDB is the first MySQL engine to provide foreign key constraints. In addition to providing transaction processing, InnoDB also supports row locks and provides consistent read without locks like Oracle, it can increase the number of concurrent read users and improve performance without increasing the number of locks. That is to say, if you want to use foreign key constraints, the table type must be InnoDB, and mysql is MyISAM by default. This type does not support foreign key constraints.

  • 1
  • 2
  • Next Page
[Content navigation]
Page 1st: Mysql foreign Key Usage considerations Page 2nd: Mysql foreign Key Usage considerations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.