Enable MySQL to support Transaction Processing

Source: Internet
Author: User
1. Insert force constraint, cascade delete, and cascade update"

 

User table:
Create Table user
(
Userid integer not null auto_increment primary key,
Username varchar (12) not null
)
Type = InnoDB;

After several attempts, I finally saw the same effect as that in ms SQL:

Insert force constraint, cascade delete, and cascade update"

When creating the password table, you must add an index to the userid column, that is:
Create Table Password
(
Userid integer not null,
Password varchar (12) not null,
Index (userid ),
Foreign key (userid) References user (userid)
On Delete Cascade
On update Cascade
) Type = InnoDB;

You can.

Sum-up:

1. MySQL supports foreign key constraints and provides the same functions as other databases, but the table type must be InnoDB.
2. index must be added to the column of the table for which the foreign key is created.

2. Enable versions earlier than 4.0 to support Transaction Processing
Add a sentence to the [mysqld] of the my. ini file.

Innodb_data_file_path = ibdata1: 10 m: autoextend

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.