Home > Database > navicat > What should I do if navicat reports error 1025 when setting foreign keys?

What should I do if navicat reports error 1025 when setting foreign keys?

爱喝马黛茶的安东尼
Release: 2019-08-20 11:47:32
Original
6089 people have browsed it

What should I do if navicat reports error 1025 when setting foreign keys?

What should I do if navicat reports error 1025 when setting foreign keys? Let me give you an example below:

Example:

Change the member table id key to bigint: alter table member modify column id BIGINT;

The following is found during execution Error:

ERROR 1025 (HY000): Error on rename of '.\test\#sql-c68_10' to '.\test\member' (errno: 150)
Copy after login

Cause:

The id primary key field of the member table is the foreign key of another address. Modifying the id field type of the main table will cause the main table to be different from the foreign key. Key associated table fields are inconsistent.

Related recommendations: "Navicat for mysql graphic tutorial"

Solution:

(1) Find the external Key related table, find the foreign key name.

(2) Delete foreign key constraints.

(3) Modify the main table (member) id field type: alter table member modify column id bigint;

(4) Modify the auxiliary table (address) member_id field type: alter table address modify column member_id bigint;

(5)Add the deleted foreign key: alter table address add constraint fk_member_address foreign key (member_id) references member(id);

The above is the detailed content of What should I do if navicat reports error 1025 when setting foreign keys?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template