Problem with database mysql
#1

I I don't know what is wrong so if you can tell me would be nice

Код:
CREATE TABLE IF NOT EXISTS `Mochilas` (
  `Id` int(10) unsigned NOT NULL,
  `Propietario` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `Mochilas`
  ADD PRIMARY KEY (`Id`),
  ADD UNIQUE KEY `Unico` (`Propietario`);

ALTER TABLE `Mochilas`
  MODIFY `Id` int(10) unsigned NOT NULL AUTO_INCREMENT;
Error #1215: Can not add foreign key constraint

Код:
CREATE TABLE IF NOT EXISTS `Items_Mochila` (
  `Id` int(10) unsigned NOT NULL,
  `Descripcion` varchar(50) NOT NULL,
  `Valor_Efecto` float NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=latin1;

INSERT INTO `Items_Mochila` (`Id`, `Descripcion`, `Valor_Efecto`) VALUES
(1, 'Hotdog sencillo', 8),
(2, 'Hotdog doble', 15),
(3, 'Hotdog ranchero', 30),
(4, 'Cono de helado', 8),
(5, 'Cucurucho', 15),
(6, 'Sundae', 30),
(7, 'Brass Knuckles', 0),
(8, 'Golf Club', 0),
(9, 'Nightstick', 0),
(10, 'Cuchillo', 0),
(11, 'Bate baseball', 0),
(12, 'Pala', 0),
(13, 'Pool Cue', 0),
(14, 'Katana', 0),
(15, 'Motosierra', 0),
(16, 'Purple Dildo', 0),
(17, 'Dildo', 0),
(18, 'Vibrator', 0),
(19, 'Silver Vibrator', 0),
(20, 'Flowers', 0),
(21, 'Cane', 0),
(22, 'Grenade', 0),
(23, 'Tear Gas', 0),
(24, 'Molotov Cocktail', 0),
(25, '9mm', 0),
(26, 'Silenced 9mm', 0),
(27, 'Desert Eagle', 0),
(28, 'Escopeta', 0),
(29, 'Escopeta recortada', 0),
(30, 'Escopeta de combate', 0),
(31, 'Micro SMG/Uzi', 0),
(32, 'MP5', 0),
(33, 'AK-47', 0),
(34, 'M4', 0),
(35, 'Tec-9', 0),
(36, 'Rifle', 0),
(37, 'Rifle francotirador', 0),
(38, 'RPG', 0),
(39, 'HS Rocket', 0),
(40, 'Lanzallamas', 0),
(41, 'Minigun', 0),
(42, 'Satchel Charge', 0),
(43, 'Detonador', 0),
(44, 'Spraycan', 0),
(45, 'Extinguidor', 0),
(46, 'Camara', 0),
(47, 'Night Vis Goggles', 0),
(48, 'Thermal Goggles	', 0);

ALTER TABLE `Items_Mochila`
  ADD PRIMARY KEY (`Id`);

ALTER TABLE `Items_Mochila`
  MODIFY `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=49;
Error #1215 - Can not add foreign key constraint
Reply
#2

Ok I already Changed the table but I've the problem again:

Quote:

CREATE TABLE IF NOT EXISTS `Items_Mochila` (
`Id` int(10) unsigned NOT NULL,
`Descripcion` varchar(50) NOT NULL,
`Valor_Efecto` float NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=latin1

ERROR: #1215 - Can not add foreign key constraint
Quote:

CREATE TABLE IF NOT EXISTS `Mochilas` (
`Id` int(10) unsigned NOT NULL,
`Propietario` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1

ERROR:#1215 - Can not add foreign key constraint
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)