MySQL Forums
Forum List  »  InnoDB

Re: ERROR 1005: Can't create table (errno: 150) - my SOLUTION
Posted by: Luca Porro
Date: September 27, 2010 02:23AM

hello, i am e newbie of mysql and i have this error in the creation of my tables...

# DROP TABLE IF EXISTS anagrafica ;

CREATE TABLE IF NOT EXISTS anagrafica(
id int(11) NOT NULL auto_increment,
id_cat int(11) UNSIGNED NOT NULL,
RagioneSociale varchar(100) NOT NULL,
Nazionalita varchar(3) NOT NULL default '',
Citta varchar(50) NOT NULL default '',
Indirizzo varchar(50) NOT NULL default '',
Telefono int(11) NOT NULL default '0',
DefStato varchar(50) default '',
PRIMARY KEY (id, id_cat)
) ENGINE=InnoDB;

# DROP TABLE IF EXISTS archivioemail;

CREATE TABLE IF NOT EXISTS archivioemail(
id_anag int(11) NOT NULL,
id_archivio int(11) NOT NULL default '0',
Referente varchar(100) NOT NULL default '',
Note varchar(250) NOT NULL default '',
email varchar(70) NOT NULL default '',
data date NOT NULL default '0000-00-00',
PRIMARY KEY (`id_anag`, `id_archivio`),
FOREIGN KEY (`id_anag`) REFERENCES `anagrafica`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

# DROP TABLE IF EXISTS categorie;

CREATE TABLE IF NOT EXISTS categorie(
`id_categorie` int(11) UNSIGNED NOT NULL,
`nome` varchar(20) NOT NULL default '',
PRIMARY KEY(`id_categorie`),
FOREIGN KEY (`id_categorie`) REFERENCES `anagrafica`(`id_cat`) ON DELETE CASCADE ON UPDATE CASCADE
)ENGINE=InnoDB;

my problem is in table categorie, i don't know how resolve this problem, in this string:
FOREIGN KEY (`id_categorie`) REFERENCES `anagrafica`(`id_cat`) ON DELETE CASCADE ON UPDATE CASCADE

help me.
thanks

Options: ReplyQuote


Subject
Views
Written By
Posted
648578
March 24, 2005 01:20PM
5421
October 09, 2012 09:48PM
3676
December 19, 2011 10:13PM
9145
May 09, 2006 06:01PM
8318
November 15, 2006 02:05PM
7362
T D
February 01, 2008 06:47AM
9176
August 27, 2008 08:08AM
9674
December 03, 2008 10:15AM
6154
May 01, 2009 07:39AM
3416
August 29, 2011 04:46PM
4999
s l
December 15, 2009 01:48PM
4923
December 22, 2009 02:54AM
3221
February 18, 2011 08:55AM
Re: ERROR 1005: Can't create table (errno: 150) - my SOLUTION
4055
September 27, 2010 02:23AM
3837
May 24, 2011 10:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.