Mysql Operational Error 1005
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of mysql error 1005 can't create table this site About Us Learn more about Stack Overflow the company Business mysql error 1005 errno 121 Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask mysql error 1005 (hy000) Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up mysql error 1005 errno 150 MySQL Foreign Key Error 1005 errno 150 up vote 31 down vote favorite 8 I'm doing a small DataBase with MySQL Workbench. I have a main table, called "Immobili", which has a Primary Key composed by four columns: (Comune, Via, Civico, Immobile). Now, I also have three other tables, wich have the same primary key (Comune, Via, Civico, Immobile), but these fields are
Error 1005 Cloudflare
also referenced to the table Immobili. First question: Can I make a Primary Key that is also a Foreign Key? Second Question: When I try to export the changes it says: Executing SQL script in server # ERROR: Error 1005: Can't create table 'dbimmobili.condoni' (errno: 150) CREATE TABLE IF NOT EXISTS `dbimmobili`.`Condoni` ( `ComuneImmobile` VARCHAR(50) NOT NULL , `ViaImmobile` VARCHAR(50) NOT NULL , `CivicoImmobile` VARCHAR(5) NOT NULL , `InternoImmobile` VARCHAR(3) NOT NULL , `ProtocolloNumero` VARCHAR(15) NULL , `DataRichiestaSanatoria` DATE NULL , `DataSanatoria` DATE NULL , `SullePartiEsclusive` TINYINT(1) NULL , `SullePartiComuni` TINYINT(1) NULL , `OblazioneInEuro` DOUBLE NULL , `TecnicoOblazione` VARCHAR(45) NULL , `TelefonoTecnico` VARCHAR(15) NULL , INDEX `ComuneImmobile` (`ComuneImmobile` ASC) , INDEX `ViaImmobile` (`ViaImmobile` ASC) , INDEX `CivicoImmobile` (`CivicoImmobile` ASC) , INDEX `InternoImmobile` (`InternoImmobile` ASC) , PRIMARY KEY (`ComuneImmobile`, `ViaImmobile`, `CivicoImmobile`, `InternoImmobile`) , CONSTRAINT `ComuneImmobile` FOREIGN KEY (`ComuneImmobile` ) REFERENCES `dbimmobili`.`Immobile` (`ComuneImmobile` ) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ViaImmobile` FOREIGN KEY (`ViaImmobile` ) REFERENCES `dbimmobili`.`Immobile` (`ViaImmobile` ) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `CivicoImmobile` FOREIGN KEY (`CivicoImmobile` ) REFERENCES `dbimmobili`.`Immobile` (`CivicoImmobile` ) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `InternoImmobile` FOREIGN KEY (`InternoImmobile` ) RE
Previous TicketNext Ticket → Opened 4 years ago Closed 4 years ago Last modified 4 years ago #18256 closed Bug (fixed) MySQL
Error 1005 Mysql
error (1005, "Can't create table '\\db_name\\.#sql-4a8_98' (errno: 150)") in error no 150 in mysql Django 1.4 Reported by: Hans Andersen Owned by: nobody Component: Documentation Version: 1.4 Severity: django db utils operationalerror 1005 Normal Keywords: mysql Cc: hans@…, timograham@… Triage Stage: Accepted Has patch: yes Needs documentation: no Needs tests: no Patch needs improvement: no Easy http://stackoverflow.com/questions/4063141/mysql-foreign-key-error-1005-errno-150 pickings: no UI/UX: no Description I am getting MySQL (errno: 150) while trying to run syncdb. I have tested the same model code on Django 1.3.1 and found no problems in running syncdb, so the issue seems to has been introduced in Django 1.4, and is affecting https://code.djangoproject.com/ticket/18256 Django 1.4+, as I has also tested on Django SVN. My system info are: Ubuntu 12.04 Python 2.7.3 Django 1.4 MySQL 5.5.22 My models are: from django.db import models from django.contrib.auth.models import User from django.utils.translation import gettext_lazy as _ class Report(models.Model): TOPIC_CHOICES = ( ... ) user = models.ForeignKey(User) topic = models.PositiveSmallIntegerField(_('Report topic'), choices=TOPIC_CHOICES, default=None) custom_text = models.TextField(_("Further comments"), \ help_text=_("It is important to give as precise a description, with as many details, of the problem as possible, for our development team to be able properly to determine your problem.")) fixed = models.BooleanField(_("The reported problem is fixed."), default=False) class ReportUnit(models.Model): TEASING_CHOICES = ( ... ) report = models.OneToOneField(Report) tease = models.PositiveSmallIntegerField(choices=TEASING_CHOICES, default=None) class ReportAdvertisement(models.Model): TEASING_CHOICES = ( ... ) report = models.OneToOneField(Report) tease = models.PositiveSmallIntegerField(choices=TEASING_CHOICES, default=None) class ReportStatistics(models.Model): TEASING_CHOICES = ( ... ) report = models.OneToOneField(Report) tease = models.PositiveSmallIntegerField(choices=TEASING_CHOICES
Community Podcasts MySQL.com Downloads Documentation Section Menu: MySQL Forums :: InnoDB :: ERROR 1005: Can't create table (errno: 150) New Topic Advanced Search ERROR 1005: Can't create table (errno: 150) Posted by: elmpie () Date: March 24, http://forums.mysql.com/read.php?22,19755,19755 2005 01:20PM I'm using the MySql version that comes with the Debian Sarge. (mysql Ver 12.22 Distrib 4.0.23, for pc-linux-gnu (i386)) I already have one database that has a few tables with foreign keys. I've created a anew database and it seems impossible to put new foreign keys on these tables? So I've tried the most basic thing ans its still not working. create table test1 (pk_alias int not null error 1005 auto_increment, primary key (pk_alias)) type=innodb; create table test2 (pk_alias2 int unsigned not null auto_increment, fk_test1 int not null, primary key (pk_alias2), foreign key (fk_test1) references test1(pk_alias)) type=innodb; I don't really get it. What am I doing wrong?? Thanks! Navigate:Previous Message•Next Message Options:Reply•Quote Subject Views Written By Posted ERROR 1005: Can't create table (errno: 150) 641336 elmpie 03/24/2005 01:20PM Re: ERROR 1005: Can't create table (errno: 150) 304119 Martin Lukasiewycz 03/28/2005 mysql error 1005 02:15PM Re: ERROR 1005: Can't create table (errno: 150) 215442 KimSeong Loh 03/29/2005 08:42PM Re: ERROR 1005: Can't create table (errno: 150) 155625 Michael Buell 05/30/2005 10:29AM Re: ERROR 1005: Can't create table (errno: 150) 149741 Chris Yuan 10/27/2005 11:01PM Re: ERROR 1005: Can't create table (errno: 150) 92347 Deepak Kumar 03/14/2008 11:45PM ERROR 1005: Can't create table (errno: 150) 72385 Pradeep Max 07/07/2008 09:00AM Re: ERROR 1005: Can't create table (errno: 150) 49769 karthik sakthi 03/12/2009 07:38AM Re: ERROR 1005: Can't create table (errno: 150) Global solution 50910 Mayur P Vegad 06/23/2010 08:13AM Re: ERROR 1005: Can't create table (errno: 150) Global solution 20533 B S 08/13/2011 09:04PM unfortunately not 4832 Gavin Stokes 10/09/2012 09:48PM Re: ERROR 1005: Can't create table (errno: 150) 37443 Agyeya Gupta 04/26/2009 06:23AM Re: ERROR 1005: Can't create table (errno: 150) 25617 Chris Walker 06/28/2009 12:40PM Re: ERROR 1005: Can't create table (errno: 150) [SOLVED] 48489 Chris Walker 06/28/2009 12:41PM Re: ERROR 1005: Can't create table (errno: 150) [SOLVED] 29147 Jitendra Gupta 09/04/2009 02:30AM Re: ERROR 1005: Can't create table (errno: 150) [ANOTHER SOLUTION] 29798 Jim Smith 01/11/2010 10:23AM Re: ERROR 1005: Can't create table (errno: 150) [ANOTHER SOLUTION] 11119 Esen Sagynov 04/17/2011 05:39AM Re: ERROR 1005: Can't create table (errno: 150