MYSQLKIRA

Chia sẽ kinh nghiệm trong quá trình học tập SQL

Full width home advertisement

Travel the world

Climb the mountains

Post Page Advertisement [Top]

SQL 1: fix xung đột dữ liệu giữa 2 table data

SQL 1: fix xung đột dữ liệu giữa 2 table data
fix lỗi

click execute

alter table Works_On
add foreign key (PNo) references Project(PNumber)

xuất hiện lỗi

Msg 547, Level 16, State 0, Line 83
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK__Works_On__PNo__5070F446". The conflict occurred in database "SQLLab2", table "dbo.Project", column 'PNumber'.


lý do
Không đồng bộ dữ liệu giữ các bảng, xảy ra xung đột dữ liệu giữa 2 table data

fix:
thêm with nocheck vào sau tên bảng

alter table Works_On with nocheck
add foreign key (PNo) references Project(PNumber)


Không có nhận xét nào:

Đăng nhận xét

Bottom Ad [Post Page]