Delete in Foreign Key

Asked

Viewed 32 times

-1

I have three tables: Students, Courses and Teachers. I am trying to run a delete in the Courses table, but it has relation to other tables. How do I perform the deletion?

create database flexPeak;
use flexPeak;
create table ALUNO(
ID_ALUNO int primary key not null auto_increment,
Nome_Aluno varchar(20) not null,
DATA_NASCIMENTO_ALUNO varchar(20) not null,
CEP_ALUNO int not null,
LOGRADOURO_ALUNO varchar (20) not null,
NUMERO_ALUNO int not null,
BAIRRO_ALUNO varchar(20) not null,  
CIDADE_ALUNO varchar(20) not null,
ESTADO_ALUNO varchar(20) not null,
DATA_CRIACAO_ALUNO varchar(20) not null,
Aluno_CURSO_ID int not null,
foreign key(Aluno_CURSO_ID) 
references CURSO(ID_CURSO)
);

create table CURSO(
ID_CURSO int primary key not null auto_increment,
NOME_CURSO varchar(20) not null,
DATA_CRIACAO_CURSO date not null,
ID_PROFESSOR_CURSO int not null ,
foreign key(ID_PROFESSOR_CURSO) 
references PROFESSOR(ID_PROFESSOR)
);

create table PROFESSOR(  
ID_PROFESSOR int not null primary key auto_increment,
NOME_PROFESSOR  varchar(20) not null,
DATA_NASCIMENTO_PROFESSOR date not null,
DATA_CRIACAO_PROFESSOR date not null
);

1 answer

-1

ALTER TABLE SUATABELA DROP CONSTRAINT FK_SUACHAVE

And try to delete your table. I hope I helped. =)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.