MySQL Forums :: Newbie :: ERROR 1005 (HY000): Can't create table 'Azienda.#sql-697_c9' (errno: 150)


Advanced Search

ERROR 1005 (HY000): Can't create table 'Azienda.#sql-697_c9' (errno: 150)
Posted by: andrea esposito ()
Date: April 02, 2011 12:11PM

Hi,all
I have this two tables:

mysql> show create table Dipartimento\G
*************************** 1. row ***************************
Table: Dipartimento
Create Table: CREATE TABLE `Dipartimento` (
`Nome` varchar(15) NOT NULL,
`Sede` varchar(15) NOT NULL,
`Telefono` varchar(13) NOT NULL,
PRIMARY KEY (`Nome`),
KEY `Sede` (`Sede`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Insieme di dipartimenti'
1 row in set (0,22 sec)

mysql> show create table Sede\G
*************************** 1. row ***************************
Table: Sede
Create Table: CREATE TABLE `Sede` (
`Citta` varchar(15) NOT NULL COMMENT 'Citt� sede di un dipartimento',
`Via` varchar(50) NOT NULL,
`NumeroCivico` varchar(4) NOT NULL,
`CAP` varchar(6) NOT NULL,
PRIMARY KEY (`Citta`),
KEY `Citta` (`Citta`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Citt� dove hanno sede i dipartimenti'
1 row in set (0,00 sec)

when I write the alter table command for adding a foreign key:

ALTER TABLE `Dipartimento` ADD FOREIGN KEY ( `Sede` ) REFERENCES `Azienda`.`Sede` (`Citta`) ON DELETE SET NULL ON UPDATE CASCADE ;

I get this error:
ERROR 1005 (HY000): Can't create table 'Azienda.#sql-697_c9' (errno: 150)
I think that this error is related to the attribute types but i can't "see" it.Any suggestion?Thank you all.

Options: ReplyQuote


Subject Written By Posted
ERROR 1005 (HY000): Can't create table 'Azienda.#sql-697_c9' (errno: 150) andrea esposito 04/02/2011 12:11PM
Re: ERROR 1005 (HY000): Can't create table 'Azienda.#sql-697_c9' (errno: 150) Rick James 04/03/2011 01:21PM
Re: ERROR 1005 (HY000): Can't create table 'Azienda.#sql-697_c9' (errno: 150) andrea esposito 04/04/2011 04:55AM
Re: ERROR 1005 (HY000): Can't create table 'Azienda.#sql-697_c9' (errno: 150) Peter Brawley 04/03/2011 03:08PM


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.