Cannot drop column needed in a foreign key constraint

Multi tool use
Multi tool use












-1















Executing SQL script in server




ERROR: Error 1829: Cannot drop column 'cod_Cliente': needed in a foreign key constraint 'fk_Cuotas_Clientes1' of table 'gimnasio.cuotas'




ALTER TABLE `Gimnasio`.`Clientes` DROP COLUMN `Observación` , 
DROP COLUMN `Cedula` , DROP COLUMN `cod_Cliente` ,
CHANGE COLUMN `FechaDeNacimiento` `FechaDeNacimiento` INT(11) NULL DEFAULT NULL,
CHANGE COLUMN `Dirección` `Dirección` VARCHAR(100) NULL DEFAULT NULL ,
ADD COLUMN `cod_Cliente` INT(11) NOT NULL FIRST ,
ADD COLUMN `Cédula` INT(11) NULL DEFAULT NULL AFTER `Apellido` ,
ADD COLUMN `Observación` VARCHAR(150) NULL DEFAULT NULL AFTER `Telefono` ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (`cod_Cliente`)


SQL script execution finished: statements: 12 succeeded, 1 failed










share|improve this question

























  • Drop the foreign key constraint before dropping the column?

    – Joe C
    Jul 11 '17 at 21:20











  • Also, please do not tag languages that have nothing to do with the question.

    – Joe C
    Jul 11 '17 at 21:21
















-1















Executing SQL script in server




ERROR: Error 1829: Cannot drop column 'cod_Cliente': needed in a foreign key constraint 'fk_Cuotas_Clientes1' of table 'gimnasio.cuotas'




ALTER TABLE `Gimnasio`.`Clientes` DROP COLUMN `Observación` , 
DROP COLUMN `Cedula` , DROP COLUMN `cod_Cliente` ,
CHANGE COLUMN `FechaDeNacimiento` `FechaDeNacimiento` INT(11) NULL DEFAULT NULL,
CHANGE COLUMN `Dirección` `Dirección` VARCHAR(100) NULL DEFAULT NULL ,
ADD COLUMN `cod_Cliente` INT(11) NOT NULL FIRST ,
ADD COLUMN `Cédula` INT(11) NULL DEFAULT NULL AFTER `Apellido` ,
ADD COLUMN `Observación` VARCHAR(150) NULL DEFAULT NULL AFTER `Telefono` ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (`cod_Cliente`)


SQL script execution finished: statements: 12 succeeded, 1 failed










share|improve this question

























  • Drop the foreign key constraint before dropping the column?

    – Joe C
    Jul 11 '17 at 21:20











  • Also, please do not tag languages that have nothing to do with the question.

    – Joe C
    Jul 11 '17 at 21:21














-1












-1








-1








Executing SQL script in server




ERROR: Error 1829: Cannot drop column 'cod_Cliente': needed in a foreign key constraint 'fk_Cuotas_Clientes1' of table 'gimnasio.cuotas'




ALTER TABLE `Gimnasio`.`Clientes` DROP COLUMN `Observación` , 
DROP COLUMN `Cedula` , DROP COLUMN `cod_Cliente` ,
CHANGE COLUMN `FechaDeNacimiento` `FechaDeNacimiento` INT(11) NULL DEFAULT NULL,
CHANGE COLUMN `Dirección` `Dirección` VARCHAR(100) NULL DEFAULT NULL ,
ADD COLUMN `cod_Cliente` INT(11) NOT NULL FIRST ,
ADD COLUMN `Cédula` INT(11) NULL DEFAULT NULL AFTER `Apellido` ,
ADD COLUMN `Observación` VARCHAR(150) NULL DEFAULT NULL AFTER `Telefono` ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (`cod_Cliente`)


SQL script execution finished: statements: 12 succeeded, 1 failed










share|improve this question
















Executing SQL script in server




ERROR: Error 1829: Cannot drop column 'cod_Cliente': needed in a foreign key constraint 'fk_Cuotas_Clientes1' of table 'gimnasio.cuotas'




ALTER TABLE `Gimnasio`.`Clientes` DROP COLUMN `Observación` , 
DROP COLUMN `Cedula` , DROP COLUMN `cod_Cliente` ,
CHANGE COLUMN `FechaDeNacimiento` `FechaDeNacimiento` INT(11) NULL DEFAULT NULL,
CHANGE COLUMN `Dirección` `Dirección` VARCHAR(100) NULL DEFAULT NULL ,
ADD COLUMN `cod_Cliente` INT(11) NOT NULL FIRST ,
ADD COLUMN `Cédula` INT(11) NULL DEFAULT NULL AFTER `Apellido` ,
ADD COLUMN `Observación` VARCHAR(150) NULL DEFAULT NULL AFTER `Telefono` ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (`cod_Cliente`)


SQL script execution finished: statements: 12 succeeded, 1 failed







java mysql database-connection






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 12 '17 at 6:30









Luciano van der Veekens

4,77541626




4,77541626










asked Jul 11 '17 at 21:18









Alberto FleitasAlberto Fleitas

1




1













  • Drop the foreign key constraint before dropping the column?

    – Joe C
    Jul 11 '17 at 21:20











  • Also, please do not tag languages that have nothing to do with the question.

    – Joe C
    Jul 11 '17 at 21:21



















  • Drop the foreign key constraint before dropping the column?

    – Joe C
    Jul 11 '17 at 21:20











  • Also, please do not tag languages that have nothing to do with the question.

    – Joe C
    Jul 11 '17 at 21:21

















Drop the foreign key constraint before dropping the column?

– Joe C
Jul 11 '17 at 21:20





Drop the foreign key constraint before dropping the column?

– Joe C
Jul 11 '17 at 21:20













Also, please do not tag languages that have nothing to do with the question.

– Joe C
Jul 11 '17 at 21:21





Also, please do not tag languages that have nothing to do with the question.

– Joe C
Jul 11 '17 at 21:21












1 Answer
1






active

oldest

votes


















1














Remove the foreign key before modifying a primary key field:



ALTER TABLE gimnasio.cuotas
DROP FOREIGN KEY fk_Cuotas_Clientes1


After that, do your ALTER TABLE.



And finally, do not forget to create again the relationship:



ALTER TABLE gimansio.cuotas ADD CONSTRAINT fk_Cuotas_Clientes1 FOREIGN KEY (col_name) REFERENCES gimnasio.Clientes(cod_Cliente);





share|improve this answer


























  • Where do i put this code?

    – Alberto Fleitas
    Jul 11 '17 at 21:47











  • I am sorry, but i am new in this

    – Alberto Fleitas
    Jul 11 '17 at 21:48











  • The first block before your instruction. And the ending block after your instruction. (Replace col_name with the column name of your table cuotas

    – Oscar Martinez
    Jul 11 '17 at 21:49













  • Do not forget to accept this as answer if it solved your problem.

    – Oscar Martinez
    Jul 11 '17 at 22:56











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45044629%2fcannot-drop-column-needed-in-a-foreign-key-constraint%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Remove the foreign key before modifying a primary key field:



ALTER TABLE gimnasio.cuotas
DROP FOREIGN KEY fk_Cuotas_Clientes1


After that, do your ALTER TABLE.



And finally, do not forget to create again the relationship:



ALTER TABLE gimansio.cuotas ADD CONSTRAINT fk_Cuotas_Clientes1 FOREIGN KEY (col_name) REFERENCES gimnasio.Clientes(cod_Cliente);





share|improve this answer


























  • Where do i put this code?

    – Alberto Fleitas
    Jul 11 '17 at 21:47











  • I am sorry, but i am new in this

    – Alberto Fleitas
    Jul 11 '17 at 21:48











  • The first block before your instruction. And the ending block after your instruction. (Replace col_name with the column name of your table cuotas

    – Oscar Martinez
    Jul 11 '17 at 21:49













  • Do not forget to accept this as answer if it solved your problem.

    – Oscar Martinez
    Jul 11 '17 at 22:56
















1














Remove the foreign key before modifying a primary key field:



ALTER TABLE gimnasio.cuotas
DROP FOREIGN KEY fk_Cuotas_Clientes1


After that, do your ALTER TABLE.



And finally, do not forget to create again the relationship:



ALTER TABLE gimansio.cuotas ADD CONSTRAINT fk_Cuotas_Clientes1 FOREIGN KEY (col_name) REFERENCES gimnasio.Clientes(cod_Cliente);





share|improve this answer


























  • Where do i put this code?

    – Alberto Fleitas
    Jul 11 '17 at 21:47











  • I am sorry, but i am new in this

    – Alberto Fleitas
    Jul 11 '17 at 21:48











  • The first block before your instruction. And the ending block after your instruction. (Replace col_name with the column name of your table cuotas

    – Oscar Martinez
    Jul 11 '17 at 21:49













  • Do not forget to accept this as answer if it solved your problem.

    – Oscar Martinez
    Jul 11 '17 at 22:56














1












1








1







Remove the foreign key before modifying a primary key field:



ALTER TABLE gimnasio.cuotas
DROP FOREIGN KEY fk_Cuotas_Clientes1


After that, do your ALTER TABLE.



And finally, do not forget to create again the relationship:



ALTER TABLE gimansio.cuotas ADD CONSTRAINT fk_Cuotas_Clientes1 FOREIGN KEY (col_name) REFERENCES gimnasio.Clientes(cod_Cliente);





share|improve this answer















Remove the foreign key before modifying a primary key field:



ALTER TABLE gimnasio.cuotas
DROP FOREIGN KEY fk_Cuotas_Clientes1


After that, do your ALTER TABLE.



And finally, do not forget to create again the relationship:



ALTER TABLE gimansio.cuotas ADD CONSTRAINT fk_Cuotas_Clientes1 FOREIGN KEY (col_name) REFERENCES gimnasio.Clientes(cod_Cliente);






share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 11 '17 at 21:31

























answered Jul 11 '17 at 21:24









Oscar MartinezOscar Martinez

4321515




4321515













  • Where do i put this code?

    – Alberto Fleitas
    Jul 11 '17 at 21:47











  • I am sorry, but i am new in this

    – Alberto Fleitas
    Jul 11 '17 at 21:48











  • The first block before your instruction. And the ending block after your instruction. (Replace col_name with the column name of your table cuotas

    – Oscar Martinez
    Jul 11 '17 at 21:49













  • Do not forget to accept this as answer if it solved your problem.

    – Oscar Martinez
    Jul 11 '17 at 22:56



















  • Where do i put this code?

    – Alberto Fleitas
    Jul 11 '17 at 21:47











  • I am sorry, but i am new in this

    – Alberto Fleitas
    Jul 11 '17 at 21:48











  • The first block before your instruction. And the ending block after your instruction. (Replace col_name with the column name of your table cuotas

    – Oscar Martinez
    Jul 11 '17 at 21:49













  • Do not forget to accept this as answer if it solved your problem.

    – Oscar Martinez
    Jul 11 '17 at 22:56

















Where do i put this code?

– Alberto Fleitas
Jul 11 '17 at 21:47





Where do i put this code?

– Alberto Fleitas
Jul 11 '17 at 21:47













I am sorry, but i am new in this

– Alberto Fleitas
Jul 11 '17 at 21:48





I am sorry, but i am new in this

– Alberto Fleitas
Jul 11 '17 at 21:48













The first block before your instruction. And the ending block after your instruction. (Replace col_name with the column name of your table cuotas

– Oscar Martinez
Jul 11 '17 at 21:49







The first block before your instruction. And the ending block after your instruction. (Replace col_name with the column name of your table cuotas

– Oscar Martinez
Jul 11 '17 at 21:49















Do not forget to accept this as answer if it solved your problem.

– Oscar Martinez
Jul 11 '17 at 22:56





Do not forget to accept this as answer if it solved your problem.

– Oscar Martinez
Jul 11 '17 at 22:56


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45044629%2fcannot-drop-column-needed-in-a-foreign-key-constraint%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







G4V VXS1 SOf,A,T77rjvBc RweKhMUWeCkg,pNpi5u7nH03r6oXyzI7v1UQvbESf gJ3Puaj bSl9zq8E2lwyxomku
46QvJfNhO2X8RUHJgVtMlc 1WyY,b4QevotKVE bILP IuzZEnTKIxAGtY4JLnn88b

Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas