create table day_news(
    id smallint unsigned auto_increment,
    title varchar(50),
    content text,
    author varchar(200),
    num int unsigned default 0,
    ntime int unsigned,
    cname varchar(50),
    hotarticle enum('y','n') default 'n',
    flag enum('y','n') default 'y',
    primary key(id),
    constraint nfk foreign key (cname) references day_newsclass(cname) on delete set null on update cascade
)engine=innodb default charset=utf8;
select * from day_newsclass;
select * from day_news;
truncate day_news;
truncate day_newsclass;
delete from day_newsclass where 1=1;
select * from day_newsclass;




另外再建外键是nfk一定要修改名字




Copyright © 2024 小蕊同学
Powered by .NET 9.0 on Kubernetes