Welcome to dbFreaks.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

errno: 150 situation

 
   Database Help (Home) -> mySQL RSS
Related Topics:
Can't open file: 'mytable.ibd' (errno: 1) - Hi, I read in the mysql manual that it's possible to copy the 'frm' files from one mysql server to another, but when I try to do this I get the error open file: (errno: 1)" on the server. There are no '.ibd' files..

Best way to issue hundreds of inserts/updates??? - Using mysql 4.0.23- What is the best way to execute several (hundreds of) inserts and updates? Rather than issuing tons of inserts and updates, can I send the strings to a text file and then have mysql do them all?? IE : query.txt insert..

MySQL freezes, brings XP machine to a grinding halt - I've been using MySQL for a while for fairly light database on my XP machine. I am just starting a new project and have some big problems with MySQL today both on my office machine and at home where running a

login as user 'root' but do not have root privlages and my.. - Hi gang: I'm a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it doesn't recognize me being logged in as root (via..

FLUSH TABLES hangs if table is locked - Using FLUSH TABLES via the C query API hangs if the table is locked already. That is to say, nothing prevents me from running a LOCK TABLES twice; it won't tell me already locked, don't try to run a Anyone know how to find..
Next:  Straightforward install, but problems!  
Author Message
nobody30

External


Since: Jan 15, 2005
Posts: 15



(Msg. 1) Posted: Thu Feb 10, 2005 10:40 pm
Post subject: errno: 150 situation
Archived from groups: mailing>database>mysql (more info?)

i'm getting an errno: 150 when creating a table and this is what i read
from the mysql manual:

"Both tables must be InnoDB type. In the referencing table, there must
be an index where the foreign key columns are listed as the first
columns in the same order. In the referenced table, there must be an
index where the referenced columns are listed as the first columns in
the same order. Index prefixes on foreign key columns are not supported."

I only understand the first statement. Can somebody help me decipher
what the other statements mean especially the following:

"where the referenced columns are listed as the first columns in the
same order"

"Index prefixes on foreign key columns are not supported"



i want to create this table

CREATE TABLE tablename
(
  from_domain_name ....
  from_url_path ...
  to_domain_name...
  to_url_path

  PRIMARY KEY(from_domain_name, from_url_path, to_domain_name, to_url_path),

  FOREIGN KEY(from_domain_name)
   REFERENCES domain(name)
    ...
    ...

  FOREIGN KEY(from_url_path)
   REFERENCES url(path)
    ...
    ...

  FOREIGN KEY(to_domain_name)
   REFERENCES domain(name)
    ...
    ...

  FOREIGN KEY(to_url_path)
   REFERENCES url(path)
    ...
    ...
 
) ENGINE=InnoDB;<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: errno: 150 situation 
Back to top
Login to vote
Bill Karwin1

External


Since: Jun 17, 2004
Posts: 42



(Msg. 2) Posted: Thu Feb 10, 2005 10:40 pm
Post subject: Re: errno: 150 situation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:
 > Can somebody help me decipher
 > what the other statements mean especially the following:
 >
 > "where the referenced columns are listed as the first columns in the
 > same order"

If you use a composite key for your reference, the fields must be in the
same order in both the referencing and referenced tables.

For example:

create table master (
a int not null,
b int not null,
c int not null,
primary key (a, b, c)
);

create table dependent (
x int,
y int,
z int,
foreign key (x, y, z) references master(a, b, c)
);

But if you make the foreign key reference anything other than (a,b,c),
for example (b,c,a) or (a,b) or (b,c), it can't check against the
primary key in the referenced table. You must list all the fields
listed in the primary key, and in the same order as they are listed in
that primary key definition.

You can mix up the order of the fields in the foreign key, but then they
might be comparing to the wrong fields in the primary key in the other
table:
foreign key (y, z, x) references master(a, b, c)
In this case, y validates against a, z validates against b, and x
validates against c.

What are your primary key definitions in your other tables url and
domain? Do you have compound keys in those tables, and you're trying to
reference them with single-field foreign keys?

 > "Index prefixes on foreign key columns are not supported"

Index prefixes are for when you have very long string fields, and you
want to index the first N characters, to help reduce the overall size of
the index data structure created. You specify the length N of the
prefix when you create the index, for example:

create index foo on myTable (veryLongVarcharField(20));

They're saying you can't use that kind of index in foreign keys, for
whatever reason.

Regards,
Bill K.<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: errno: 150 situation 
Back to top
Login to vote
nobody30

External


Since: Jan 15, 2005
Posts: 15



(Msg. 3) Posted: Fri Feb 11, 2005 8:40 am
Post subject: Re: errno: 150 situation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Bill Karwin wrote:
 > For example:
 >
 > create table master (
 > a int not null,
 > b int not null,
 > c int not null,
 > primary key (a, b, c)
 > );
 >
 > create table dependent (
 > x int,
 > y int,
 > z int,
 > foreign key (x, y, z) references master(a, b, c)
 > );

somehow i managed to solve the problem by include "INDEX(path)" in the
referenced table. this even works when i removed the TYPE=INNODB
although the manual said it must be an innodb type. will the
constraints work during runtime eventhough it can compile?<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: errno: 150 situation 
Back to top
Login to vote
Bill Karwin1

External


Since: Jun 17, 2004
Posts: 42



(Msg. 4) Posted: Fri Feb 11, 2005 11:38 am
Post subject: Re: errno: 150 situation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

- wrote:
 > somehow i managed to solve the problem by include "INDEX(path)" in the
 > referenced table.

Aha, so the path fields in the other tables weren't indexed? That was
definitely your problem.

 > this even works when i removed the TYPE=INNODB
 > although the manual said it must be an innodb type. will the
 > constraints work during runtime eventhough it can compile?

The constraints will *not* work if you don't make the tables InnoDB.
When you declare a foreign key in a MyISAM table, MySQL accepts the
declaration, but does not enforce the constraint. In other words, you
_are_ permitted to insert values even if they don't occur in the
referenced table.

"In MySQL 3.23.44 and up, InnoDB tables support checking of foreign key
constraints."
<a style='text-decoration: underline;' href="http://dev.mysql.com/doc/mysql/en/example-foreign-keys.html" target="_blank">http://dev.mysql.com/doc/mysql/en/example-foreign-keys.html</a>

Regards,
Bill K.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: errno: 150 situation 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> mySQL All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]