MySQL Forums
Forum List  »  Spanish

Re: PROBLEMA CON FOREIGN KEY (FK) MYSQL
Posted by: Gonzalo Garcia Correas
Date: November 26, 2009 07:27AM

Tienes un error de sitaxis, cuando indicas a qué tabla hace referencia una FK también tienes que indicar a qué campo se hace referencia:
ALTER TABLE matricula
ADD CONSTRAINT fk_matricula_curso
FOREIGN KEY idcurso
REFERENCES `curso`(`idcurso`);

Se requiere eso porque no hay forma en que MySQL sepa cuál es el campo, ya que el mismo podría tener un nombre diferente al que aparece en la tabla referenciada.

Options: ReplyQuote


Subject
Views
Written By
Posted
47509
July 11, 2006 07:51AM
3765
February 25, 2010 05:22PM
3123
November 09, 2010 06:58AM
5167
June 07, 2010 03:05PM
3402
August 31, 2011 05:59AM
7385
August 30, 2006 09:33AM
8044
November 14, 2007 03:15AM
4288
June 13, 2011 08:59AM
11596
February 12, 2008 06:04PM
7449
March 11, 2008 05:17AM
4050
April 10, 2010 06:07PM
8265
August 25, 2008 07:22PM
8648
March 23, 2008 09:27AM
5328
April 19, 2008 05:08PM
4828
May 11, 2008 12:28PM
7241
March 28, 2008 10:20AM
6386
June 05, 2008 08:21AM
4808
May 20, 2009 06:30PM
7367
April 18, 2008 12:52PM
4485
May 20, 2009 06:27PM
5290
April 30, 2008 02:21PM
5065
June 05, 2008 08:02AM
6957
May 02, 2008 01:15PM
5077
May 08, 2008 08:13PM
5174
May 08, 2008 09:05AM
7430
June 04, 2008 01:47PM
4743
May 29, 2008 04:34AM
4791
May 29, 2008 05:54AM
5059
June 02, 2008 11:47AM
9861
June 04, 2008 02:01PM
5832
June 05, 2008 07:46AM
6428
June 09, 2008 02:31AM
4540
June 09, 2008 09:53AM
4922
June 11, 2008 10:47AM
5390
June 16, 2008 06:28AM
7465
September 03, 2008 04:34PM
9339
September 05, 2008 04:09AM
5191
December 14, 2008 11:49AM
7407
May 19, 2009 08:31AM
4709
May 19, 2009 08:43AM
3970
July 29, 2009 08:59AM
3933
August 02, 2009 09:19PM
4702
August 02, 2009 03:18PM
4400
August 28, 2009 06:55PM
7639
August 31, 2009 03:02PM
4634
September 14, 2009 01:54PM
4705
September 24, 2009 09:43PM
3885
September 25, 2009 09:30AM
4161
October 07, 2009 01:51AM
5458
November 05, 2009 05:09PM
4086
November 25, 2009 06:51AM
Re: PROBLEMA CON FOREIGN KEY (FK) MYSQL
6737
November 26, 2009 07:27AM
3259
November 26, 2009 04:13AM
3768
December 28, 2009 10:31PM
4301
February 02, 2010 09:55AM
8913
February 12, 2010 08:35AM
4184
March 01, 2010 03:08PM
3438
March 03, 2010 08:23AM
5239
March 05, 2010 07:57AM
2983
March 06, 2010 04:37PM
4622
April 13, 2010 03:43PM
3192
August 08, 2010 03:15PM
2676
August 08, 2010 03:54PM
2041
September 15, 2010 10:06AM
9565
September 18, 2010 10:24AM
2205
October 10, 2010 10:05AM
1969
November 13, 2010 05:53AM
2138
October 18, 2010 04:05PM
1973
October 18, 2010 07:34PM
1996
January 20, 2011 03:13PM
3010
February 14, 2011 09:18AM
2822
January 31, 2011 04:19PM
2877
February 02, 2011 11:41AM
1836
March 17, 2011 01:35PM
2090
July 30, 2011 10:51PM
1470
August 15, 2011 03:50PM
2346
September 20, 2011 10:54AM
1314
September 20, 2011 01:53PM


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.