You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
set @@global.tidb_enable_foreign_key=1;
set @@foreign_key_checks=1;
createtablet1 (id int key,a int, index(a));
createtablet2 (id int key,a int);
insert into t1 values (1,1);
test> ALTER TABLE t1 ADD foreign key fk(a) references t2(id) ON DELETE CASCADE;
(1452, 'Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `fk` FOREIGN KEY (`a`) REFERENCES `t2` (`id`) ON DELETE CASCADE)')
test> show create table t1\G
***************************[ 1. row ]***************************
Table | t1
Create Table | CREATE TABLE `t1` (
`id`int(11) NOT NULL,
`a`int(11) DEFAULT NULL,
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
KEY `a` (`a`),
CONSTRAINT`fk`FOREIGN KEY (`a`) REFERENCES`test`.`t2` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
Add foreign key failed, but show create table result still contain the foreign key info.
TiDB Version
***************************[ 1. row ]***************************
tidb_version() | Release Version: v6.5.0-alpha-248-g6b4739f170
Edition: Community
Git Commit Hash: 6b4739f170a1fb53a10d3f4bd50ad6288460f252
Git Branch: master
UTC Build Time: 2022-12-0206:31:34
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore
The text was updated successfully, but these errors were encountered:
Reproduce
Add foreign key failed, but
show create table
result still contain the foreign key info.TiDB Version
The text was updated successfully, but these errors were encountered: