Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
newbie: error 1005, cannot create table
Old
  (#1)
Jeff
Guest
 
Posts: n/a
Default newbie: error 1005, cannot create table - 06-04-2007, 07:49 AM

Hey

MySql 5.0

When trying to create the Property table (see below) I get this error
message:
ERROR 1005 (HY000): Can't create table '.\demo\property.frm' (errno: 150)

Any suggestions to what I'm doing wrong here?

create table User (
UserId int unsigned not null auto_increment primary key,
UserForname varchar(50) not null
);

create table Property (
PropertyId int unsigned not null auto_increment primary key,
PropertyOwner int not null,
index idxPropertyOwner using hash (PropertyOwner),
foreign key (PropertyOwner) references User(UserId) on delete cascade
);


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: newbie: error 1005, cannot create table
Old
  (#2)
Felix Geerinckx
Guest
 
Posts: n/a
Default Re: newbie: error 1005, cannot create table - 06-04-2007, 07:49 AM

"Jeff" <EMAIL REMOVED> wrote in news:1uidnR8xTp-
EMAIL REMOVED:


> When trying to create the Property table (see below) I get this error
> message: ERROR 1005 (HY000): Can't create table '.\demo\property.frm'
> (errno: 150)
>
> create table User (
> UserId int unsigned not null auto_increment primary key,
> UserForname varchar(50) not null
> );
>
> create table Property (
> PropertyId int unsigned not null auto_increment primary key,
> PropertyOwner int not null,
> index idxPropertyOwner using hash (PropertyOwner),
> foreign key (PropertyOwner) references User(UserId) on delete cascade
> );


Because of the foreign key constraint, the datatypes of User.UserId and
Property.PropertyOwner should be *exactly* the same.

Why are you using a hash-index? As far as I can tell, it's only supported
for MEMORY tables. And MEMORY tables cannot enforce referential
integrity.


--
felix
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: newbie: error 1005, cannot create table
Old
  (#3)
Captain Paralytic
Guest
 
Posts: n/a
Default Re: newbie: error 1005, cannot create table - 06-04-2007, 07:49 AM


Jeff wrote:

> Hey
>
> MySql 5.0
>
> When trying to create the Property table (see below) I get this error
> message:
> ERROR 1005 (HY000): Can't create table '.\demo\property.frm' (errno: 150)
>
> Any suggestions to what I'm doing wrong here?
>
> create table User (
> UserId int unsigned not null auto_increment primary key,
> UserForname varchar(50) not null
> );
>
> create table Property (
> PropertyId int unsigned not null auto_increment primary key,
> PropertyOwner int not null,
> index idxPropertyOwner using hash (PropertyOwner),
> foreign key (PropertyOwner) references User(UserId) on delete cascade
> );


You have a mismatch on the field types. User.Userid is an unsigned int,
whereas Property.PropertyOwner is just int.

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: newbie: error 1005, cannot create table
Old
  (#4)
Harald Fuchs
Guest
 
Posts: n/a
Default Re: newbie: error 1005, cannot create table - 06-04-2007, 07:49 AM

In article <1uidnR8xTp-EMAIL REMOVED>,
"Jeff" <EMAIL REMOVED> writes:

> Hey
> MySql 5.0


> When trying to create the Property table (see below) I get this error
> message:
> ERROR 1005 (HY000): Can't create table '.\demo\property.frm' (errno: 150)


> Any suggestions to what I'm doing wrong here?


> create table User (
> UserId int unsigned not null auto_increment primary key,
> UserForname varchar(50) not null
> );


> create table Property (
> PropertyId int unsigned not null auto_increment primary key,
> PropertyOwner int not null,
> index idxPropertyOwner using hash (PropertyOwner),
> foreign key (PropertyOwner) references User(UserId) on delete cascade
> );


In foreign keys, the types of the referencing and the referenced
column must be the same. You've got INT vs. INT UNSIGNED.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: newbie: error 1005, cannot create table
Old
  (#5)
Jeff
Guest
 
Posts: n/a
Default Re: newbie: error 1005, cannot create table - 06-04-2007, 07:49 AM


"Harald Fuchs" <EMAIL REMOVED> wrote in message
newsEMAIL REMOVED...
> In article <1uidnR8xTp-EMAIL REMOVED>,
> "Jeff" <EMAIL REMOVED> writes:
>
>> Hey
>> MySql 5.0

>
>> When trying to create the Property table (see below) I get this error
>> message:
>> ERROR 1005 (HY000): Can't create table '.\demo\property.frm' (errno: 150)

>
>> Any suggestions to what I'm doing wrong here?

>
>> create table User (
>> UserId int unsigned not null auto_increment primary key,
>> UserForname varchar(50) not null
>> );

>
>> create table Property (
>> PropertyId int unsigned not null auto_increment primary key,
>> PropertyOwner int not null,
>> index idxPropertyOwner using hash (PropertyOwner),
>> foreign key (PropertyOwner) references User(UserId) on delete cascade
>> );

>
> In foreign keys, the types of the referencing and the referenced
> column must be the same. You've got INT vs. INT UNSIGNED.


thanks to you all, it was the datatype mismatch


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top