MySQL Workbench - Error ERROR 1215 (HY000) with foreign key constraint
up vote
0
down vote
favorite
i have the following two tables:
I need to add UT as foreign key for Id_UT, but the entries in "referenced column" disappear.
It seems to me that all the constraints for the key values are satisfied (datatype, size, uniqueness). What can be wrong here?. Thank you.
Here a minimum working example:
-- MySQL dump 10.13 Distrib 5.7.17, for Win32 (AMD64)
--
-- Host: 127.0.0.1 Database: newschema
-- ------------------------------------------------------
-- Server version 5.7.17
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `catalogo_reperti`
--
DROP TABLE IF EXISTS `catalogo_reperti`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_reperti` (
`UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Id_Reperto` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Documentazione` text COLLATE utf16_unicode_ci,
PRIMARY KEY (`Id_Reperto`,`UT`),
UNIQUE KEY `Id_Reperto_UNIQUE` (`Id_Reperto`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `catalogo_unita_topografiche`
--
DROP TABLE IF EXISTS `catalogo_unita_topografiche`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_unita_topografiche` (
`Id_UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
PRIMARY KEY (`Id_UT`),
UNIQUE KEY `Id_UT_UNIQUE` (`Id_UT`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
mysql sql mysql-workbench
|
show 8 more comments
up vote
0
down vote
favorite
i have the following two tables:
I need to add UT as foreign key for Id_UT, but the entries in "referenced column" disappear.
It seems to me that all the constraints for the key values are satisfied (datatype, size, uniqueness). What can be wrong here?. Thank you.
Here a minimum working example:
-- MySQL dump 10.13 Distrib 5.7.17, for Win32 (AMD64)
--
-- Host: 127.0.0.1 Database: newschema
-- ------------------------------------------------------
-- Server version 5.7.17
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `catalogo_reperti`
--
DROP TABLE IF EXISTS `catalogo_reperti`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_reperti` (
`UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Id_Reperto` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Documentazione` text COLLATE utf16_unicode_ci,
PRIMARY KEY (`Id_Reperto`,`UT`),
UNIQUE KEY `Id_Reperto_UNIQUE` (`Id_Reperto`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `catalogo_unita_topografiche`
--
DROP TABLE IF EXISTS `catalogo_unita_topografiche`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_unita_topografiche` (
`Id_UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
PRIMARY KEY (`Id_UT`),
UNIQUE KEY `Id_UT_UNIQUE` (`Id_UT`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
mysql sql mysql-workbench
2
It's not entirely clear what you are asking. Are you trying to create a foreign key and get an error message, or does the foreign key disappear, or something else?
– Henning Koehler
2 days ago
The foreign key simply disappears from "referenced column". If I use the alter table command, it returns a generic 1215 error.
– Discipulos
2 days ago
@Discipulos take a look at the following link. It might helps you MySQL : ERROR 1215 (HY000): Cannot add foreign key constraint
– Mohammad Mohabbati
2 days ago
I have already checked the question, but all constraints here seem correct and the alter table command returns an error.
– Discipulos
2 days ago
Could be that Id_UT contains values that don't exist in the other table. The FK constraint would then be violated already when it is created.
– GolezTrol
2 days ago
|
show 8 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i have the following two tables:
I need to add UT as foreign key for Id_UT, but the entries in "referenced column" disappear.
It seems to me that all the constraints for the key values are satisfied (datatype, size, uniqueness). What can be wrong here?. Thank you.
Here a minimum working example:
-- MySQL dump 10.13 Distrib 5.7.17, for Win32 (AMD64)
--
-- Host: 127.0.0.1 Database: newschema
-- ------------------------------------------------------
-- Server version 5.7.17
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `catalogo_reperti`
--
DROP TABLE IF EXISTS `catalogo_reperti`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_reperti` (
`UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Id_Reperto` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Documentazione` text COLLATE utf16_unicode_ci,
PRIMARY KEY (`Id_Reperto`,`UT`),
UNIQUE KEY `Id_Reperto_UNIQUE` (`Id_Reperto`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `catalogo_unita_topografiche`
--
DROP TABLE IF EXISTS `catalogo_unita_topografiche`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_unita_topografiche` (
`Id_UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
PRIMARY KEY (`Id_UT`),
UNIQUE KEY `Id_UT_UNIQUE` (`Id_UT`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
mysql sql mysql-workbench
i have the following two tables:
I need to add UT as foreign key for Id_UT, but the entries in "referenced column" disappear.
It seems to me that all the constraints for the key values are satisfied (datatype, size, uniqueness). What can be wrong here?. Thank you.
Here a minimum working example:
-- MySQL dump 10.13 Distrib 5.7.17, for Win32 (AMD64)
--
-- Host: 127.0.0.1 Database: newschema
-- ------------------------------------------------------
-- Server version 5.7.17
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `catalogo_reperti`
--
DROP TABLE IF EXISTS `catalogo_reperti`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_reperti` (
`UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Id_Reperto` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Documentazione` text COLLATE utf16_unicode_ci,
PRIMARY KEY (`Id_Reperto`,`UT`),
UNIQUE KEY `Id_Reperto_UNIQUE` (`Id_Reperto`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `catalogo_unita_topografiche`
--
DROP TABLE IF EXISTS `catalogo_unita_topografiche`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_unita_topografiche` (
`Id_UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
PRIMARY KEY (`Id_UT`),
UNIQUE KEY `Id_UT_UNIQUE` (`Id_UT`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- MySQL dump 10.13 Distrib 5.7.17, for Win32 (AMD64)
--
-- Host: 127.0.0.1 Database: newschema
-- ------------------------------------------------------
-- Server version 5.7.17
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `catalogo_reperti`
--
DROP TABLE IF EXISTS `catalogo_reperti`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_reperti` (
`UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Id_Reperto` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Documentazione` text COLLATE utf16_unicode_ci,
PRIMARY KEY (`Id_Reperto`,`UT`),
UNIQUE KEY `Id_Reperto_UNIQUE` (`Id_Reperto`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `catalogo_unita_topografiche`
--
DROP TABLE IF EXISTS `catalogo_unita_topografiche`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_unita_topografiche` (
`Id_UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
PRIMARY KEY (`Id_UT`),
UNIQUE KEY `Id_UT_UNIQUE` (`Id_UT`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- MySQL dump 10.13 Distrib 5.7.17, for Win32 (AMD64)
--
-- Host: 127.0.0.1 Database: newschema
-- ------------------------------------------------------
-- Server version 5.7.17
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `catalogo_reperti`
--
DROP TABLE IF EXISTS `catalogo_reperti`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_reperti` (
`UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Id_Reperto` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
`Documentazione` text COLLATE utf16_unicode_ci,
PRIMARY KEY (`Id_Reperto`,`UT`),
UNIQUE KEY `Id_Reperto_UNIQUE` (`Id_Reperto`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `catalogo_unita_topografiche`
--
DROP TABLE IF EXISTS `catalogo_unita_topografiche`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalogo_unita_topografiche` (
`Id_UT` varchar(45) COLLATE utf16_unicode_ci NOT NULL,
PRIMARY KEY (`Id_UT`),
UNIQUE KEY `Id_UT_UNIQUE` (`Id_UT`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
mysql sql mysql-workbench
mysql sql mysql-workbench
edited 2 days ago
asked 2 days ago
Discipulos
155113
155113
2
It's not entirely clear what you are asking. Are you trying to create a foreign key and get an error message, or does the foreign key disappear, or something else?
– Henning Koehler
2 days ago
The foreign key simply disappears from "referenced column". If I use the alter table command, it returns a generic 1215 error.
– Discipulos
2 days ago
@Discipulos take a look at the following link. It might helps you MySQL : ERROR 1215 (HY000): Cannot add foreign key constraint
– Mohammad Mohabbati
2 days ago
I have already checked the question, but all constraints here seem correct and the alter table command returns an error.
– Discipulos
2 days ago
Could be that Id_UT contains values that don't exist in the other table. The FK constraint would then be violated already when it is created.
– GolezTrol
2 days ago
|
show 8 more comments
2
It's not entirely clear what you are asking. Are you trying to create a foreign key and get an error message, or does the foreign key disappear, or something else?
– Henning Koehler
2 days ago
The foreign key simply disappears from "referenced column". If I use the alter table command, it returns a generic 1215 error.
– Discipulos
2 days ago
@Discipulos take a look at the following link. It might helps you MySQL : ERROR 1215 (HY000): Cannot add foreign key constraint
– Mohammad Mohabbati
2 days ago
I have already checked the question, but all constraints here seem correct and the alter table command returns an error.
– Discipulos
2 days ago
Could be that Id_UT contains values that don't exist in the other table. The FK constraint would then be violated already when it is created.
– GolezTrol
2 days ago
2
2
It's not entirely clear what you are asking. Are you trying to create a foreign key and get an error message, or does the foreign key disappear, or something else?
– Henning Koehler
2 days ago
It's not entirely clear what you are asking. Are you trying to create a foreign key and get an error message, or does the foreign key disappear, or something else?
– Henning Koehler
2 days ago
The foreign key simply disappears from "referenced column". If I use the alter table command, it returns a generic 1215 error.
– Discipulos
2 days ago
The foreign key simply disappears from "referenced column". If I use the alter table command, it returns a generic 1215 error.
– Discipulos
2 days ago
@Discipulos take a look at the following link. It might helps you MySQL : ERROR 1215 (HY000): Cannot add foreign key constraint
– Mohammad Mohabbati
2 days ago
@Discipulos take a look at the following link. It might helps you MySQL : ERROR 1215 (HY000): Cannot add foreign key constraint
– Mohammad Mohabbati
2 days ago
I have already checked the question, but all constraints here seem correct and the alter table command returns an error.
– Discipulos
2 days ago
I have already checked the question, but all constraints here seem correct and the alter table command returns an error.
– Discipulos
2 days ago
Could be that Id_UT contains values that don't exist in the other table. The FK constraint would then be violated already when it is created.
– GolezTrol
2 days ago
Could be that Id_UT contains values that don't exist in the other table. The FK constraint would then be violated already when it is created.
– GolezTrol
2 days ago
|
show 8 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
Forcing the declaration of Charset/collation (instead of leaving the default ones, which anyway are set to be the same) allows the program to declare the foreign key.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Forcing the declaration of Charset/collation (instead of leaving the default ones, which anyway are set to be the same) allows the program to declare the foreign key.
add a comment |
up vote
0
down vote
Forcing the declaration of Charset/collation (instead of leaving the default ones, which anyway are set to be the same) allows the program to declare the foreign key.
add a comment |
up vote
0
down vote
up vote
0
down vote
Forcing the declaration of Charset/collation (instead of leaving the default ones, which anyway are set to be the same) allows the program to declare the foreign key.
Forcing the declaration of Charset/collation (instead of leaving the default ones, which anyway are set to be the same) allows the program to declare the foreign key.
answered 2 days ago
Discipulos
155113
155113
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238316%2fmysql-workbench-error-error-1215-hy000-with-foreign-key-constraint%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
It's not entirely clear what you are asking. Are you trying to create a foreign key and get an error message, or does the foreign key disappear, or something else?
– Henning Koehler
2 days ago
The foreign key simply disappears from "referenced column". If I use the alter table command, it returns a generic 1215 error.
– Discipulos
2 days ago
@Discipulos take a look at the following link. It might helps you MySQL : ERROR 1215 (HY000): Cannot add foreign key constraint
– Mohammad Mohabbati
2 days ago
I have already checked the question, but all constraints here seem correct and the alter table command returns an error.
– Discipulos
2 days ago
Could be that Id_UT contains values that don't exist in the other table. The FK constraint would then be violated already when it is created.
– GolezTrol
2 days ago