Re: Can not add foreign key constraint

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

Re: Can not add foreign key constraint

2017-04-27 Thread Johan De Meersman
t; `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`) > R

Re: Can not add foreign key constraint

2017-04-27 Thread David Mehler
nt(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_domains` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREME

Re: Can not add foreign key constraint

2017-04-25 Thread David Mehler
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; >> >> CRE

Re: Can not add foreign key constraint

2017-04-24 Thread Peter Brawley
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; CREATE TABLE IF NOT EXISTS `lastauth` ( `user` varchar(40) NOT NULL, `remote_ip` varchar(18) NOT NULL, `timestamp` tim

Re: Can not add foreign key constraint

2017-04-24 Thread David Mehler
er` (`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 NOT NULL DEFAULT CURRENT_TIMESTAMP

Re: Can not add foreign key constraint

2017-04-24 Thread David Mehler
ut. I hope it helps. >> >> root@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 David Mehler
-> 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]&

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): C

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
T EXISTS `lastauth` ( >>>> -> `user` varchar(40) NOT NULL, >>>> -> `remote_ip` varchar(18) NOT NULL, >>>> -> `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON >>>> UPDATE CURRENT_TIMESTA

Re: Can not add foreign key constraint

2017-04-24 Thread Peter Brawley
ISTS `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 virtual_users(u

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 >> CASCADE >>

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; E

Re: Can not add foreign key constraint

2017-04-24 Thread David Mehler
` 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): Cannot add foreign key cons

Re: Can not add foreign key constraints

2017-04-24 Thread Peter Brawley
id` int(11) NOT NULL 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`), FO

Re: Can not add foreign key constraints

2017-04-24 Thread Reindl Harald
id` int(11) NOT NULL 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`), FO

Can not add foreign key constraints

2017-04-24 Thread David Mehler
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) REFERENCES virtual_domains(id) ON DELE

Re: alter table for foreign key

2014-11-17 Thread thufir
ULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `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 |

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
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)
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

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: 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: ht

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 p

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 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 REFER

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 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 CA

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 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),

Re: Foreign-key naming

2012-12-12 Thread hsv
lt; Well, you're right, a work can refer to people in at least two different 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

Re: Foreign key and uppercase / lowercase values

2012-06-18 Thread GF
Sent: Friday, 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

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 >>releasin

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. However,

RE: Foreign key and uppercase / lowercase values

2012-06-15 Thread Rick James
acle.com] > Sent: 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 creat

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 a

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: R

Re: Foreign key and uppercase / lowercase values

2012-06-15 Thread GF
row in set (0.00 sec) select 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 u

RE: Foreign key and uppercase / lowercase values

2012-06-13 Thread Rick James
m > Subject: Re: 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_con

Re: Foreign key and uppercase / lowercase values

2012-06-12 Thread GF
in set (0.00 sec) 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 mea

Re: Foreign key and uppercase / lowercase values

2012-05-16 Thread Shawn Green
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 to solve this

RE: Foreign key and uppercase / lowercase values

2012-05-16 Thread Rick James
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

Re: Foreign key and uppercase / lowercase values

2012-05-16 Thread Ananda Kumar
cative 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

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

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

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 wrote: > Hi > > An ideas why MySQL silently ignores any foreign key constraints I define > for > the following tables? > &g

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 wrote: > Hi > > An ideas why MySQL silently ignores any foreign key constraints I define > for > the following tables? > &g

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 | Ex

Re: Newbie question: Association table and Foreign Key

2011-03-01 Thread S�ndor Hal�sz
have multiple categories and from what I've 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 linka

Re: Newbie question: Association table and Foreign Key

2011-03-01 Thread Wagyu Beef
Primary Key: categoryID >> >> >> The idea is that an event may have multiple categories and from what I've >> read here (http://lists.mysql.com/mysql/171645), many-to-many >> relationships >> in the database should be avoid. According to the link and a c

Re: Newbie question: Association table and Foreign Key

2011-03-01 Thread Dhaval Jaiswal
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. Can I get some help. Thanks a million! Regards, Suren This e

Newbie question: Association table and Foreign Key

2011-03-01 Thread Wagyu Beef
gories and from what I've 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 Fo

managing a foreign key constraint over two databases

2011-02-21 Thread James Smith
following 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)

Re: Foreign Key Error

2011-02-14 Thread Victor Subervi
gt; -Original Message- > From: 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

RE: Foreign Key Error

2011-02-14 Thread Gavin Towey
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 not null, foreign key (Parent) references categories (ID), Child integer not nul

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 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 *indice

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, but the

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 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

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 "

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 ? For

Re: Foreign Key Problem

2010-06-22 Thread Victor Subervi
On Tue, Jun 22, 2010 at 11:53 AM, jayabharath 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 > error. > Than

Re: Foreign Key Problem

2010-06-22 Thread jayabharath
ds: 1 Duplicates: 0 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 (

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

Foreign Key Problem

2010-06-22 Thread Victor Subervi
ights 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> alter table Pilots type=InnoDB; Que

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 Flight

Re: Another Foreign Key Problem

2010-05-21 Thread Victor Subervi
b64/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

Another Foreign Key Problem

2010-05-21 Thread Victor Subervi
execute self.errorhandler(self, exc, value) 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 (`seaf

Re: Foreign Key Problem

2010-05-20 Thread Victor Subervi
On Wed, May 19, 2010 at 12:02 PM, Shawn Green wrote: > Victor Subervi wrote: > >> On Wed, May 19, 2010 at 10:59 AM, Shawn Green > >wrote: >> >> Shawn Green wrote: >> >> > look again closely at your FK definitions. The pattern should be >>

Re: Foreign Key Problem

2010-05-19 Thread Shawn Green
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 not

Re: Foreign Key Problem

2010-05-19 Thread Victor Subervi
ble (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 a

Re: Foreign Key Problem

2010-05-19 Thread Shawn Green
ble if not exists Passengers (id int(11) 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; Please help me see where I'm stumbling. All the fields have the same ty

Re: Foreign Key Problem

2010-05-19 Thread Victor Subervi
On Tue, May 18, 2010 at 2:23 PM, Shawn Green wrote: > Shawn Green wrote: > I may be confused but how can the ID of the Passengers table be both the ID > of the Flight they are taking and their Customer ID at the same time? > > http://dev.mysql.com/doc/refman/5.1/en/inn

Re: Foreign Key Problem

2010-05-18 Thread Shawn Green
: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 to: ), constraint fo

Re: Foreign Key Problem

2010-05-18 Thread Victor Subervi
On Tue, May 18, 2010 at 1:09 PM, Shawn Green wrote: > 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 seafl

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 wrote: 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-leve

Re: Foreign Key Problem

2010-05-18 Thread Johan De Meersman
On Tue, May 18, 2010 at 6:00 PM, Victor Subervi wrote: > > > 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 (

Re: Foreign Key Problem

2010-05-18 Thread Victor Subervi
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)) engine=InnoDB; ERROR 1005 (HY000): Can't create table './seaf

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

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>

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, 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 > na

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

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 s

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 exe

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 -Ori

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

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) REFE

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 wrote: > Hi, > > I tried to remove foreign key constraint in innodb tabl

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: 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

how to add foreign key in alter command

2009-05-16 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: 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 > Sorry all, I was being a dummy! Missed the unsigned

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,

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

Re: Algorithm for resolving foreign key dependencies?

2009-02-03 Thread Peter Brawley
_schema,u.table_name,u.column_name,u.referenced_column_name FROM information_schema.table_constraints AS c INNER JOIN information_schema.key_column_usage AS u USING( constraint_schema, constraint_name ) WHERE c.constraint_type = 'FOREIGN KEY' AND u.referenced_table_schema='db' AND u.referenced_t

Re: Algorithm for resolving foreign key dependencies?

2009-02-03 Thread ddevaudreuil
lam 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

Re: Algorithm for resolving foreign key dependencies?

2009-02-03 Thread Andrew Garner
cts in order of their foreign-key dependency.""" ~Andrew On Tue, Feb 3, 2009 at 3:40 PM, Philip Pemberton 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 > da

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

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 th

  1   2   3   4   5   6   7   >