Part 1
1

Chapter 2 :
Supprimer des tables

Exemple sur la suppression de table : Example SQL n°2

The questions should help you understand the code shown below.
Once you hold the solution, you can view the answer by clicking on the question title.

1.Pourquoi cette requête échoue-t-elle ?

R : Une contrainte de clé étrangère bloque la requête. Si on supprime la table CLIENTS, alors il y aura des codeclient inconnus dans la table Locations.

2.Comment faut il procéder pour supprimer la table Clients ?

R : Il faut soit commencer par supprimer la table Locations, soit supprimer la contrainte de clé étrangère.
Validated example
DROP TABLE Clients;
Table Clients (codecli, prenomcli, nomcli, ruecli, cpcli, villecli)
Primary key : codecli

Table Films (codefilm, nomfilm)
Primary key : codefilm

Table Locations (codecli, codefilm, datedebut, duree)
Primary key : codecli, codefilm
Foreign key : codefilm of the table Films, codecli of the table Clients

An execution error has been thrown.
FOREIGN KEY constraint failed
2 / 2
Exemple sur la suppression de table