使用外键从多朋友表中删除数据

时间:2019-05-02 11:18:50

标签: mysql sql

我想从播放器表中删除一个播放器,但它显示我必须先删除外键数据

Table structure for table matchinfo
Column  Type    Null    Default
matchinfo_id    int(11) No  
match_id    int(11) No  
match_info  longtext    No

Table structure for table matchplaying11
Column  Type    Null    Default
mp11_id int(11) No  
match_id    int(11) No  
team_id int(11) No  
player1 int(11) No  fk(player_id)
player2 int(11) No  fk(player_id)
player3 int(11) No  fk(player_id)
player4 int(11) No  fk(player_id)
player5 int(11) No  fk(player_id)
player6 int(11) No  fk(player_id)
player7 int(11) No  fk(player_id)
player8 int(11) No  fk(player_id)
player9 int(11) No  fk(player_id)
player10    int(11) No  fk(player_id)
player11    int(11) No  fk(player_id)
captain int(11) No  fk(player_id)
vice_captain    int(11) No  fk(player_id)
wicket_keeper   int(11) No  fk(player_id)

Table structure for table matchscore_ball
Column  Type    Null    Default
msball_id   int(11) No  
match_id    int(11) No  
team_id int(11) No  
player_id   int(11) No  fk(player_id)
ball    int(11) No  
run int(11) No  
maiden  float   No  
wickets int(11) No  
economy int(11) No  
inning_1or2 int(11) No  

Table structure for table matchscore_bat
Column  Type    Null    Default
msbat_id    int(11) No  
match_id    int(11) No  
team_id int(11) No  
player_id   int(11) No  fk(player_id)
inning_1or2 int(11) No  
run int(11) No  
ball    int(11) No  
strike_rate int(11) No  
four    int(11) No  
six int(11) No  
wicket_by   int(11) No  fk(player_id)
caught_by   int(11) No  fk(player_id)
stumped_by  int(11) No  fk(player_id)
runout_direct   int(11) No  fk(player_id)
runout1 int(11) No  fk(player_id)
runout2 int(11) No  fk(player_id)

Table structure for table news
Column  Type    Null    Default
news_id int(11) No  
team_id int(11) No  
player_id   int(11) No  fk(player_id)
news_info   longtext    No  

Table structure for table player
Column  Type    Null    Default
player_id   int(11) No primary key  
player_name varchar(30) No  
player_country  varchar(30) No  
player_bday date    No  
player_type varchar(30) No  
batting_style   varchar(30) No  
bowling_style   varchar(30) No  
player_info longtext    No  

Table structure for table playerdebutlast
Column  Type    Null    Default
pdl_id  int(11) No  
player_id   int(11) No  fk(player_id)
t20_debut   varchar(30) No  
t20_lastplayed  varchar(30) No  
odi_debut   varchar(30) No  
odi_lastplayed  varchar(30) No  
test_debut  varchar(30) No  
test_lastplayed varchar(30) No  

Table structure for table playerteam
Column  Type    Null    Default
pt_id   int(11) No  
player_id   int(11) No  fk(player_id)
team1   int(11) No  
team2   int(11) No  
team3   int(11) No  
team4   int(11) No  
team5   int(11) No  
other_team  varchar(60) No

** abpve是被称为fk(player_id)的表和前键。

所以我应该使用什么查询从具有外键的所有表中删除播放器。

是否可以在单个查询中删除,或者我应该使用多伙伴查询? **

0 个答案:

没有答案