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