Re: Can not add foreign key constraint

2017-04-28 Thread David Mehler
bigint(20) NOT NULL DEFAULT '0', >> `quota_messages` int(11) NOT NULL DEFAULT '0', >> PRIMARY KEY (`id`), >> UNIQUE KEY `UNIQUE_EMAIL` (`domain_id`,`user`), &

Re: Can not add foreign key constraint

2017-04-28 Thread Johan De Meersman
varchar(128) NOT NULL, > `quota` bigint(20) NOT NULL DEFAULT '0', > `quota_messages` int(11) NOT NULL DEFAULT '0', > PRIMARY KEY (`id`), > UNIQUE KEY `UNIQUE_EMAIL` (`domain_id`,`user`), > CONSTRAINT `virtual_users_ibfk_1` FOREIGN KEY (`domain_id`) > REFERENCES `virtual_domai

Re: Can not add foreign key constraint

2017-04-27 Thread David Mehler
DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `UNIQUE_EMAIL` (`domain_id`,`user`), CONSTRAINT `virtual_users_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `virtual_domains` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8

Re: Can not add foreign key constraint

2017-04-25 Thread David Mehler
ota` bigint(20) NOT NULL DEFAULT 256, >>`quota_messages` int(11) NOT NULL DEFAULT 0, >>PRIMARY KEY (`id`), >>UNIQUE KEY `user` (`user`), >>FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE >> CASCADE >> ) ENGINE=InnoDB DEFAULT CHARSET=utf8; &

Re: Can not add foreign key constraint

2017-04-24 Thread Peter Brawley
, PRIMARY KEY (`id`), UNIQUE KEY `user` (`user`), FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `lastauth` ( `user` varchar(40) NOT NULL, `remote_ip` varchar(18) NOT NULL, `timestamp` timestamp

Re: Can not add foreign key constraint

2017-04-24 Thread David Mehler
`), FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `lastauth` ( `user` varchar(40) NOT NULL, `remote_ip` varchar(18) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE

Re: Can not add foreign key constraint

2017-04-24 Thread David Mehler
MESTAMP ON >> UPDATE CURRENT_TIMESTAMP, >> -> PRIMARY KEY (`user`), >> -> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE >> CASCADE >> -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Re: Can not add foreign key constraint

2017-04-24 Thread David Mehler
gt; PRIMARY KEY (`user`), -> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE CASCADE -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ERROR 1215 (HY000): Cannot add foreign key constraint root@localhost [mail]> s

Re: Can not add foreign key constraint

2017-04-24 Thread Peter Brawley
-> `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -> PRIMARY KEY (`user`), -> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE CASCADE -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ERROR 1215 (HY000):

Re: Can not add foreign key constraint

2017-04-24 Thread shawn l.green
) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY (`user`), FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `lastauth` ( `user` varchar(40) NOT NULL, `remote_ip` varchar(18) NOT NULL

Re: Can not add foreign key constraint

2017-04-24 Thread David Mehler
localhost [mail]> CREATE TABLE IF NOT EXISTS `lastauth` ( >>>> -> `user` varchar(40) NOT NULL, >>>> -> `remote_ip` varchar(18) NOT NULL, >>>> -> `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON >&

Re: Can not add foreign key constraint

2017-04-24 Thread Peter Brawley
E IF NOT EXISTS `lastauth` ( -> `user` varchar(40) NOT NULL, -> `remote_ip` varchar(18) NOT NULL, -> `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -> PRIMARY KEY (`user`), -> FOREIGN KEY (user) REFERENCES

Re: Can not add foreign key constraint

2017-04-24 Thread David Mehler
-> `remote_ip` varchar(18) NOT NULL, >>-> `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON >>UPDATE CURRENT_TIMESTAMP, >>-> PRIMARY KEY (`user`), >>-> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE >> C

Re: Can not add foreign key constraint

2017-04-24 Thread Peter Brawley
` varchar(18) NOT NULL, -> `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -> PRIMARY KEY (`user`), -> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE CASCADE -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ERROR

Re: Can not add foreign key constraint

2017-04-24 Thread David Mehler
estamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -> PRIMARY KEY (`user`), -> FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE CASCADE -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ERROR 1215 (HY000): Cannot add foreign key constrain

Re: Can not add foreign key constraints

2017-04-24 Thread Peter Brawley
auto_increment, `domain_id` int(11) NOT NULL, `user` varchar(40) NOT NULL, `password` varchar(128) NOT NULL, `quota` bigint(20) NOT NULL DEFAULT 256, `quota_messages` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `user` (`user`), FOREIGN KEY (domain_id

Re: Can not add foreign key constraints

2017-04-24 Thread Reindl Harald
auto_increment, `domain_id` int(11) NOT NULL, `user` varchar(40) NOT NULL, `password` varchar(128) NOT NULL, `quota` bigint(20) NOT NULL DEFAULT 256, `quota_messages` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `user` (`user`), FOREIGN KEY (domain_id

Can not add foreign key constraints

2017-04-24 Thread David Mehler
, `user` varchar(40) NOT NULL, `password` varchar(128) NOT NULL, `quota` bigint(20) NOT NULL DEFAULT 256, `quota_messages` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `user` (`user`), FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE ) ENGINE

alter table for foreign key

2014-11-17 Thread thufir
Looking at the docs: http://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html how do I alter the child table, links, so that it has a foreign key with the parent table, feeds? The feed_id field in links should, in fact, be constrained by the foreign key of feeds with a RESTRICT

Re: alter table for foreign key

2014-11-17 Thread Martijn Tonies (Upscene Productions)
Hi, This is an example: ALTER TABLE cart ADD CONSTRAINT fk_cart_customers FOREIGN KEY (custid) REFERENCES customers (custid) ON DELETE CASCADE ON UPDATE NO ACTION; (take from the GUI tool Database Workbench, avoids having to know the syntax ;) ) With regards, Martijn Tonies Upscene

Re: alter table for foreign key

2014-11-17 Thread thufir
On 14-11-17 01:42 AM, thufir wrote: Looking at the docs: http://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html how do I alter the child table, links, so that it has a foreign key with the parent table, feeds? The workbench GUI came up with: ALTER TABLE `rome_aggregator

Re: alter table for foreign key

2014-11-17 Thread Martijn Tonies (Upscene Productions)
On 14-11-17 01:42 AM, thufir wrote: Looking at the docs: http://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html how do I alter the child table, links, so that it has a foreign key with the parent table, feeds? The workbench GUI came up with: ALTER TABLE `rome_aggregator

Re: alter table for foreign key

2014-11-17 Thread thufir
`UNQ_links_0` (`link`), KEY `fk_links_1_idx` (`feed_id`), CONSTRAINT `fk_links_1` FOREIGN KEY (`feed_id`) REFERENCES `feeds` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=270 DEFAULT CHARSET=latin1 | I'll be reading a bit more about this. thanks, Thufir -- MySQL

Re: Foreign-key reference

2014-01-07 Thread hsv
2014/01/06 14:24 -0500, Morgan Tocker You might be hitting: Important The inline REFERENCES specifications where the references are defined as part of the column specification are silently ignored. MySQL only accepts REFERENCES clauses defined as part of a separate FOREIGN KEY specification

Re: Foreign-key reference

2014-01-07 Thread Morgan Tocker
Ugh, that seems quite right. Now, why did they do that? It was added for compatibility. A separate specification is less convenient, and also less transparent. Please click affects me on http://bugs.mysql.com/bug.php?id=47771 - Morgan -- MySQL General Mailing List For list archives:

Foreign-key reference

2014-01-06 Thread hsv
Are INNODB foreign-key references ignored in 5.6? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql

Re: Foreign-key reference

2014-01-06 Thread Morgan Tocker
On 1/6/2014, 12:21 PM, h...@tbbs.net wrote: Are INNODB foreign-key references ignored in 5.6? You might be hitting: Important The inline REFERENCES specifications where the references are defined as part of the column specification are silently ignored. MySQL only accepts REFERENCES clauses

Re: Foreign-key reference

2014-01-06 Thread Reindl Harald
Am 06.01.2014 18:21, schrieb h...@tbbs.net: Are INNODB foreign-key references ignored in 5.6? why should they? http://www.catb.org/~esr/faqs/smart-questions.html#beprecise signature.asc Description: OpenPGP digital signature

Re: Foreign key on multiple columns

2013-03-21 Thread Peter Brawley
On 2013-03-21 8:12 AM, Norah Jones wrote: I'm trying to create a foreign key on two columns but getting error... Here's what I tried: CREATE TABLE test2 ( ID INT NOT NULL AUTO_INCREMENT, col1 INT NOT NULL, col2 INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT

Re: Foreign key on multiple columns

2013-03-21 Thread shawn green
On 3/21/2013 12:43 PM, Abhishek Choudhary wrote: CREATE TABLE test2 ( ID INT NOT NULL AUTO_INCREMENT, col1 INT NOT NULL, col2 INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk FOREIGN KEY (col1, col2) REFERENCES test1(ID

Re: Foreign key on multiple columns

2013-03-21 Thread Abhishek Choudhary
      CREATE TABLE test2 (         ID INT NOT NULL AUTO_INCREMENT,         col1 INT NOT NULL,         col2 INT NOT NULL,         PRIMARY KEY (ID),         CONSTRAINT fk FOREIGN KEY (col1, col2)                       REFERENCES test1(ID, ID)         ON UPDATE CASCADE         ON DELETE RESTRICT

Re: Foreign-key naming

2012-12-12 Thread hsv
aspects, there is the work's author, and the work s owner. Neither is appropriate for the same name as found in a list of people, because now a distinction is made in the undifferentiated mass. And, yes, in general I suspect that if in one table there are more foreign-key references to the same

Re: Foreign key and uppercase / lowercase values

2012-06-18 Thread GF
, June 15, 2012 12:45 AM To: Rick James Cc: Shawn Green; mysql@lists.mysql.com Subject: Re: Foreign key and uppercase / lowercase values I think the following might give complete information (I removed some columns not involved in the problem) Server version: 5.1.49-3 (Debian) SET

Re: Foreign key and uppercase / lowercase values

2012-06-15 Thread GF
USER_ID from TBL_USER where USER_ID = 'giuseppe'; +--+ | USER_ID | +--+ | GIUSEPPE | +--+ 1 row in set (0.00 sec) update TBL_USER set USER_ID = LOWER(USER_ID) where USER_ID = 'GIUSEPPE'; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails

RE: Foreign key and uppercase / lowercase values

2012-06-15 Thread Rick James
You are very close to a standalone test case. Please create such. Then post it on bugs.mysql.com . -Original Message- From: GF [mailto:gan...@gmail.com] Sent: Friday, June 15, 2012 12:45 AM To: Rick James Cc: Shawn Green; mysql@lists.mysql.com Subject: Re: Foreign key

Re: Foreign key and uppercase / lowercase values

2012-06-15 Thread Shawn Green
Subject: Re: Foreign key and uppercase / lowercase values I think the following might give complete information (I removed some columns not involved in the problem) Server version: 5.1.49-3 (Debian) SET collation_connection = utf8_unicode_ci; Query OK, 0 rows affected ... Before he submits

RE: Foreign key and uppercase / lowercase values

2012-06-15 Thread Rick James
: Friday, June 15, 2012 12:06 PM To: Rick James Cc: GF; mysql@lists.mysql.com Subject: Re: Foreign key and uppercase / lowercase values On 6/15/2012 1:00 PM, Rick James wrote: You are very close to a standalone test case. Please create such. Then post it on bugs.mysql.com . -Original

Re: Foreign key and uppercase / lowercase values

2012-06-15 Thread Shawn Green
On 6/15/2012 3:19 PM, Rick James wrote: Those refer _only_ to German 'ß' LATIN SMALL LETTER SHARP S. The example GF gave did not involve that character. To my knowledge, that is the only case where MySQL changed a collation after releasing it. Yes, it has been the only occurrence.

Re: Foreign key and uppercase / lowercase values

2012-06-15 Thread Walter Tross
At 16.40 15/06/2012 -0400, Shawn Green wrote: On 6/15/2012 3:19 PM, Rick James wrote: Those refer _only_ to German 'ß' LATIN SMALL LETTER SHARP S. The example GF gave did not involve that character. To my knowledge, that is the only case where MySQL changed a collation after releasing it.

RE: Foreign key and uppercase / lowercase values

2012-06-13 Thread Rick James
: Foreign key and uppercase / lowercase values Good morning. The application is Java. The database version is : Server version: 5.1.49-3 (Debian) This is an example of the problem: __ mysql SET collation_connection = utf8_unicode_ci; Query OK, 0 rows affected (0.00 sec

Re: Foreign key and uppercase / lowercase values

2012-06-12 Thread GF
) mysql update MY_TABLE set USER_ID = LOWER(USER_ID) where USER_ID = 'XXYYZZ'; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails etc. etc. __ Since the used collation is _ci (I suppose it means case insensitive) I don't understand why

Foreign key and uppercase / lowercase values

2012-05-16 Thread GF
Good morning, I have an application where the user ids were stored lowercase. Some batch import, in the user table some users stored a uppercase id, and for some applicative logic, in other tables that have a foreign key to the user table, their user ids are stored lowercase. MySQL didn't throw

Re: Foreign key and uppercase / lowercase values

2012-05-16 Thread Ananda Kumar
applicative logic, in other tables that have a foreign key to the user table, their user ids are stored lowercase. MySQL didn't throw any error probalby because the collation used is case insensitive. My problem is that the application is Java and java strings are case sensitive, so now I want to set

RE: Foreign key and uppercase / lowercase values

2012-05-16 Thread Rick James
... for further discussion. Instead of changing the data, why not do the casefolding as you SELECT into Java? -Original Message- From: Ananda Kumar [mailto:anan...@gmail.com] Sent: Wednesday, May 16, 2012 3:43 AM To: GF Cc: mysql@lists.mysql.com Subject: Re: Foreign key and uppercase / lowercase

Re: Foreign key and uppercase / lowercase values

2012-05-16 Thread Shawn Green
morning, I have an application where the user ids were stored lowercase. Some batch import, in the user table some users stored a uppercase id, and for some applicative logic, in other tables that have a foreign key to the user table, their user ids are stored lowercase. ... Have you any idea how

MySQL ignores foreign key constraints

2011-05-20 Thread Mimi Cafe
Hi An ideas why MySQL silently ignores any foreign key constraints I define for the following tables? mysql desc book; +--+---+--+-+-+- --+ | Field| Type | Null | Key | Default | Extra

Re: MySQL ignores foreign key constraints

2011-05-20 Thread Andrew Moore
Try show create table ... ; A On Fri, May 20, 2011 at 12:07 PM, Mimi Cafe mimic...@googlemail.com wrote: Hi An ideas why MySQL silently ignores any foreign key constraints I define for the following tables? mysql desc book

Re: MySQL ignores foreign key constraints

2011-05-20 Thread Suresh Kuna
WHat are the table engine types ? On Fri, May 20, 2011 at 4:37 PM, Mimi Cafe mimic...@googlemail.com wrote: Hi An ideas why MySQL silently ignores any foreign key constraints I define for the following tables? mysql desc book

RE: MySQL ignores foreign key constraints

2011-05-20 Thread Mimi Cafe
Aha, got the offender. Unlike all other ones, tables book_author was MyISAM instead of Innodb. Now everything works alter table book_author add foreign key (fkauthor_id) references author (pkauthor_id); Query OK, 12 rows affected (0.39 sec) Records: 12 Duplicates: 0 Warnings: 0

Newbie question: Association table and Foreign Key

2011-03-01 Thread Wagyu Beef
read here (http://lists.mysql.com/mysql/171645), many-to-many relationships in the database should be avoid. According to the link and a couple of others I found, I'm supposed to create a separate events_categories table and make linkages using a Foreign Key. Am not sure how to translate

Re: Newbie question: Association table and Foreign Key

2011-03-01 Thread Dhaval Jaiswal
and a couple of others I found, I'm supposed to create a separate events_categories table and make linkages using a Foreign Key. Am not sure how to translate this to a SQL query. Can I get some help. Thanks a million! Regards, Suren font Face='Arial' style='font-size:9pt'This e-mail

Re: Newbie question: Association table and Foreign Key

2011-03-01 Thread Wagyu Beef
a separate events_categories table and make linkages using a Foreign Key. Am not sure how to translate this to a SQL query. Can I get some help. Thanks a million! Regards, Suren font Face='Arial' style='font-size:9pt'This e-mail, and any attachments are strictly confidential and may

Re: Newbie question: Association table and Foreign Key

2011-03-01 Thread S�ndor Hal�sz
://lists.mysql.com/mysql/171645), many-to-many relationships in the database should be avoid. According to the link and a couple of others I found, I'm supposed to create a separate events_categories table and make linkages using a Foreign Key. Am not sure how to translate this to a SQL query

managing a foreign key constraint over two databases

2011-02-21 Thread James Smith
tables. In fact this is a simplified view to capture the essentials: FILE ID NAME DATA DELETED THEME = ID NAME ... DELETED FILE_THEME == FILE_ID THEME_ID FOREIGN KEY (FILE_ID) REFERENCES FILE(ID) FOREIGN KEY (THEME_ID) REFERENCES THEME(ID) Because

Foreign Key Error

2011-02-14 Thread Victor Subervi
Hi; I have this command: create table if not exists categoriesRelationships (ID integer auto_increment primary key, Store varchar(60), Parent integer not null, foreign key (Parent) references categories (ID), Child integer not null, foreign key (Child) references categories (ID)) engine=innodb

RE: Foreign Key Error

2011-02-14 Thread Gavin Towey
To: mysql@lists.mysql.com Subject: Foreign Key Error Hi; I have this command: create table if not exists categoriesRelationships (ID integer auto_increment primary key, Store varchar(60), Parent integer not null, foreign key (Parent) references categories (ID), Child integer not null, foreign key

Re: Foreign Key Error

2011-02-14 Thread Victor Subervi
: Victor Subervi [mailto:victorsube...@gmail.com] Sent: Monday, February 14, 2011 3:09 PM To: mysql@lists.mysql.com Subject: Foreign Key Error Hi; I have this command: create table if not exists categoriesRelationships (ID integer auto_increment primary key, Store varchar(60), Parent integer

Re: Foreign key with more columns and a constant value

2010-10-24 Thread Johan De Meersman
The idea of a foreign key is that is is, well, a *foreign key* :-) It's meant to match up data that is in one table with data that is in another table, and a constant obviously isn't data in your table. To be precise, what you specify in your constraint are not even fields, but *indices

Foreign key with more columns and a constant value

2010-10-23 Thread Octavian R��ni��
Hi, I have the following table: create table client( id int unsigned not null auto_increment primary key, name varchar(200), type1 int unsigned not null, type2 int unsigned not null, constraint foreign key(type1, type2) references constants(id, type) ) engine=InnoDB; This table is OK

Re: Retrieving table and field a foreign key references

2010-07-03 Thread Peter Brawley
For example, the following do not provide this information: - show create table address; - describe address; - select * from TABLE_CONSTRAINTS; - select * from key_column_usage; For tables not using transactional engines like InnoDB, MySQL discards foreign key specs, otherwise see Find

Re: Retrieving table and field a foreign key references

2010-07-03 Thread Baron Schwartz
Kris, You can use SHOW CREATE TABLE. On Fri, Jul 2, 2010 at 7:56 PM, Kris mk...@gmx.net wrote: Hello, I am having trouble finding a way to retrieve the table and field a foreign key references by querying MySQL. If you look at the following example tables, there is no way after the tables

Retrieving table and field a foreign key references

2010-07-02 Thread Kris
Hello, I am having trouble finding a way to retrieve the table and field a foreign key references by querying MySQL. If you look at the following example tables, there is no way after the tables are created to learn that: - address.sid actually references state.id Is this possible

Foreign Key Problem

2010-06-22 Thread Victor Subervi
key (pilot_id) references Pilots (id); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`seaflight/#sql-4d89_3ac`, CONSTRAINT `#sql-4d89_3ac_ibfk_1` FOREIGN KEY (`pilot_id`) REFERENCES `Pilots` (`id`)) mysql alter table Pilots type=InnoDB; Query OK, 1 row

Re: Foreign Key Problem

2010-06-22 Thread Victor Subervi
Problem solved. I tried everything that *should* have worked and didn't. Then I just wiped the test database and started with everything *fixed* (all engine=innodb, all keys of same type, etc.) and it all worked. V

Re: Foreign Key Problem

2010-06-22 Thread jayabharath
Warnings: 0 mysql alter table Flights add foreign key (pilot_id) references Pilots (id); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`seaflight/#sql-4d89_3ac`, CONSTRAINT `#sql-4d89_3ac_ibfk_1` FOREIGN KEY (`pilot_id`) REFERENCES `Pilots` (`id`)) mysql

Re: Foreign Key Problem

2010-06-22 Thread Victor Subervi
On Tue, Jun 22, 2010 at 11:53 AM, jayabharath jbhara...@gmail.com wrote: Hi Victor, The actual problem is with the key field. Flights.pilot_id is set to INT NOT NULL and you had specified Pilots.id to INT NULL. You have to change both the columns to NULL or else NOT NULL to avoid the

Re: Foreign Key Problem

2010-05-22 Thread Victor Subervi
This is just for the sake of future googlers of this thread. The correct mysql command is: ursor.execute('create table if not exists Passengers (id int(11) auto_increment primary key, flights_id int(11) not null, customer_id int(11) not null, foreign key (flights_id) references Flights (id

Another Foreign Key Problem

2010-05-21 Thread Victor Subervi
) File /usr/lib64/python2.4/site-packages/MySQLdb/connections.py, line 35, in defaulterrorhandler raise errorclass, errorvalue OperationalError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`seaflight/Baggage`, CONSTRAINT `Baggage_ibfk_2` FOREIGN KEY (`customer_id

Re: Another Foreign Key Problem

2010-05-21 Thread Victor Subervi
, errorvalue OperationalError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`seaflight/Baggage`, CONSTRAINT `Baggage_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `Customers` (`id`))') However, when I try from the MySQL prompt after duly printing it out from the code

Re: Foreign Key Problem

2010-05-20 Thread Victor Subervi
On Wed, May 19, 2010 at 12:02 PM, Shawn Green shawn.l.gr...@oracle.comwrote: Victor Subervi wrote: On Wed, May 19, 2010 at 10:59 AM, Shawn Green shawn.l.gr...@oracle.com wrote: Shawn Green wrote: look again closely at your FK definitions. The pattern should be FOREIGN KEY

Re: Foreign Key Problem

2010-05-19 Thread Victor Subervi
-foreign-key-constraints.html You may want additional ID columns in the Passengers table to point to the parent values in those other tables. Please help me out here. This is what I have: mysql describe Customers

Re: Foreign Key Problem

2010-05-19 Thread Shawn Green
/refman/5.1/en/innodb-foreign-key-constraints.html You may want additional ID columns in the Passengers table to point to the parent values in those other tables. Please help me out here. This is what I have: mysql describe Customers

Re: Foreign Key Problem

2010-05-19 Thread Victor Subervi
on this table (the child table) with the correct column on the parent table (either Flights or Customers). You need to declare two more fields before you can link them through a Foreign Key relationship to a field on another table: CREATE TABLE PASSENGERS ( id int auto_increment , flights_id int

Re: Foreign Key Problem

2010-05-19 Thread Shawn Green
the columns on this table (the child table) with the correct column on the parent table (either Flights or Customers). You need to declare two more fields before you can link them through a Foreign Key relationship to a field on another table: CREATE TABLE PASSENGERS ( id int auto_increment

Foreign Key Problem

2010-05-18 Thread Victor Subervi
Hi; mysql create table if not exists Passengers (id int unsigned auto_increment primary key, foreign key (id) references Flights (flights_id), foreign key (id) references Customers (customer_id), name varchar(40), weight tinyint(3)); Query OK, 0 rows affected (0.00 sec) mysql select c.first_name

Re: Foreign Key Problem

2010-05-18 Thread Johan De Meersman
; mysql create table if not exists Passengers (id int unsigned auto_increment primary key, foreign key (id) references Flights (flights_id), foreign key (id) references Customers (customer_id), name varchar(40), weight tinyint(3)); Query OK, 0 rows affected (0.00 sec) mysql select c.first_name

Re: Foreign Key Problem

2010-05-18 Thread Victor Subervi
Passengers (id int unsigned auto_increment primary key, foreign key (id) references Flights (flights_id), foreign key (id) references Customers (customer_id), name varchar(40), weight tinyint(3)) engine=InnoDB; ERROR 1005 (HY000): Can't create table './seaflight/Passengers.frm' (errno: 150) So

Re: Foreign Key Problem

2010-05-18 Thread Johan De Meersman
On Tue, May 18, 2010 at 6:00 PM, Victor Subervi victorsube...@gmail.comwrote: So apparently it didn't like my foreign key. Do I need to do something with the table I'm referencing or what? TIA. Well, quickfix is to convert your tables to innoDB, starting with the lowest-level (foreign-key

Re: Foreign Key Problem

2010-05-18 Thread Shawn Green
Johan De Meersman wrote: On Tue, May 18, 2010 at 6:00 PM, Victor Subervi victorsube...@gmail.comwrote: So apparently it didn't like my foreign key. Do I need to do something with the table I'm referencing or what? TIA. Well, quickfix is to convert your tables to innoDB, starting

Re: Foreign Key Problem

2010-05-18 Thread Victor Subervi
On Tue, May 18, 2010 at 1:09 PM, Shawn Green shawn.l.gr...@oracle.comwrote: Johan De Meersman wrote: For additional details about failed FK attempts, check the error details in the SHOW INNODB STATUS report. I get this: 100518 10:26:22 Error in foreign key constraint of table seaflight

Re: Foreign Key Problem

2010-05-18 Thread Shawn Green
this: 100518 10:26:22 Error in foreign key constraint of table seaflight/Passengers: constraint foreign key (id) references Flights (flights_id), constraint foreign key (id) references Customers (customer_id), name varchar(40), weight tinyint(3)) engine=InnoDB: Cannot resolve column name close

Can't create foreign key

2010-05-14 Thread jc
I'm trying to create a foreign key by executing the following statement: ALTER TABLE `cc`.`takenlessons` ADD CONSTRAINT `fk_lessons` FOREIGN KEY (`LessonID` ) REFERENCES `cc`.`lessons` (`id` ) ON DELETE CASCADE ON UPDATE NO ACTION , ADD INDEX `fk_lessons` (`LessonID` ASC

RE: Can't create foreign key

2010-05-14 Thread Gavin Towey
Perror 121 says: OS error code 121: Remote I/O error Which I'm not too sure why an ALTER to add an constraint would give that error. Normally though, foreign key errors are shown in the SHOW ENGINE INNODB STATUS \G output, look for more details there. Regards, Gavin Towey -Original

Re: Can't create foreign key

2010-05-14 Thread Carsten Pedersen
Haven't done this in a while, but I'm guessing that you can't create both a constraint and an index with the same name? Type mismatch will in my experience most often generate an errno 150. / Carsten j...@msdlg.com skrev: I'm trying to create a foreign key by executing the following

RE: Can't create foreign key

2010-05-14 Thread jc
Interesting. Thanks for that tip on showing the INNODB STATUS. It turned up the error: A foreign key constraint of name `cc/fk_lessons` already exists. ...which tells me that a foreign key name cannot already be in use even if on a different table (at least that's what it appears to be saying

RE: Can't create foreign key

2010-05-14 Thread jc
Nope, that wasn't the problem. I wasn't aware that the foreign key name must be unique. So, if you have a foreign key named fk_lesson, that same name cannot exist already, even if on a different table. I named the foreign key something completely different and that solved the problem. Jesse

Re: Can't create foreign key

2010-05-14 Thread Prabhat Kumar
I have faced the same issue in past. * key name must be a unique*. On Fri, May 14, 2010 at 11:33 PM, j...@msdlg.com wrote: Nope, that wasn't the problem. I wasn't aware that the foreign key name must be unique. So, if you have a foreign key named fk_lesson, that same name cannot exist

Remove - Foreign key constraint in innodb

2010-02-25 Thread Vikram A
Hi, I tried to remove foreign key constraint in innodb table. I tried with different ways; but i am unable to drop the constraints. http://lists.mysql.com/mysql/113053 It says that, droping the foreign key constraint it is not possible in innodb engine. Is it so? or any other possibilities

Re: Remove - Foreign key constraint in innodb

2010-02-25 Thread Jim Lyons
Yes - you can drop a foreign key constraint, use the 'alter table ... drop foreign key ...' command. If you get an error message, post the error message. On Thu, Feb 25, 2010 at 6:03 AM, Vikram A vikkiatb...@yahoo.in wrote: Hi, I tried to remove foreign key constraint in innodb table. I

Re: Remove - Foreign key constraint in innodb

2010-02-25 Thread Jesper Wisborg Krogh
An example how to delete a foreign key from an InnoDB table: test CREATE TABLE table_1 (id int unsigned NOT NULL auto_increment PRIMARY KEY) ENGINE=InnoDB; Query OK, 0 rows affected (0.56 sec) test CREATE TABLE table_2 (table1_id int unsigned NOT NULL, FOREIGN KEY (table1_id) REFERENCES

how to add foreign key in alter command

2009-05-17 Thread Nathan Huang
Hi guys Please tell me the command syntax, how to add a colmmen foreign key in alter syntax thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org

RE: how to add foreign key in alter command

2009-05-17 Thread abdulazeez alugo
Date: Sun, 17 May 2009 14:25:55 +0800 From: nathan.vorbei.t...@gmail.com To: mysql@lists.mysql.com Subject: how to add foreign key in alter command Hi guys Please tell me the command syntax, how to add a colmmen foreign key in alter syntax thanks Hello Nathan, Try

Foreign Key Issue

2009-03-26 Thread John Daisley
Hi, I have the script below to create 5 tables. Three of them create fine but two return an error of 150 which I understand to be a foreign key issue, however I can't see anything wrong with the foreign key statements. Could someone possibly have a look and see if they can identify the issue

SOLVED: Re: Foreign Key Issue

2009-03-26 Thread John Daisley
Sorry all, I was being a dummy! Missed the unsigned attribute off the foreign key columns on the problem tables. Regards Hi, I have the script below to create 5 tables. Three of them create fine but two return an error of 150 which I understand to be a foreign key issue, however I can't

Re: SOLVED: Re: Foreign Key Issue

2009-03-26 Thread Claudio Nanni
I had the same problem and was going crazy, the ket/foreign key fields must be exactly the same. I 'forward' engineered the database with MySQL Workbench and was almost posting a bug! Cheers Claudio 2009/3/26 John Daisley john.dais...@mypostoffice.co.uk Sorry all, I was being a dummy

Algorithm for resolving foreign key dependencies?

2009-02-03 Thread Philip Pemberton
trouble with is the DELETE code generator -- more specifically, resolving foreign key references. Basically, what I have is a tree built in memory, so I can go: tableinfo['thetable']['fieldname']['refs'] And get a complete list of all the tables (and the fields within that table) that reference

Re: Algorithm for resolving foreign key dependencies?

2009-02-03 Thread ddevaudreuil
: Andy Shellam wrote: Am I missing something here? (It is late after a long day, I admit!) Only something I forgot to mention. All the foreign keys are set up as ON DELETE RESTRICT, meaning MySQL's response to a foreign key violation is to spit out an error message to the effect of I'm

Re: Algorithm for resolving foreign key dependencies?

2009-02-03 Thread Andrew Garner
of their foreign-key dependency. ~Andrew On Tue, Feb 3, 2009 at 3:40 PM, Philip Pemberton usene...@philpem.me.uk wrote: Hi, First of all, I apologise in advance for any mind-altering, or headache-inducing effects this question may have. I've spent the past two days trying to figure it out, and all

Re: Algorithm for resolving foreign key dependencies?

2009-02-03 Thread Philip Pemberton
Andy Shellam wrote: Am I missing something here? (It is late after a long day, I admit!) Only something I forgot to mention. All the foreign keys are set up as ON DELETE RESTRICT, meaning MySQL's response to a foreign key violation is to spit out an error message to the effect of I'm sorry

Re: Algorithm for resolving foreign key dependencies?

2009-02-03 Thread Andy Shellam
Hi Philip, Am I missing something here? (It is late after a long day, I admit!) In the example case you've given, if the foreign key in Parts is set to ON DELETE CASCADE, and you delete a row from Manufacturer, MySQL will first delete the associated records in Parts before deleting the row

  1   2   3   4   5   6   7   >