How to use MySQL foreign key

Methods of using MySQL external keys: 1. The two tables must be InnoDB table types; 2. The domain used in the foreign key relationship must be an index type Index; 3. The domain used in the foreign key relationship must be of the same data type resemblance. 【Related learning recommendation: mysql tutorial(video)】 Methods of using MySQL external keys: 1. Only InnoDB tables can use foreign keys. Mysql defaults to MyISAM, which does not support foreign key constraints 2. The benefits of foreign keys: it can make two tables associated, ensure data consistency and realize some cascading operations. 3. The role of foreign keys: To maintain data consistency and integrity, the main purpose is to control the data stored in foreign key tables. To associate two tables, the foreign key can only refer to the values ​​of the columns in the foreign table. 4. The prerequisite for establishing a foreign key: The two tables must be of the InnoDB table type. The field used in the foreign key relationship must be an index type (Index). The field used in the foreign key relationship must be similar to the data type. 5. Steps of creation Specify the primary key keyword: foreign key…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索