我与数据库中的category_id列有一个外部关系,但在删除时得到了错误。这是我的删除代码:
public function destroy($id)
{
$category = Category::find($id);
$category->delete();
Session::flash('success', 'The category was successfully deleted.');
return redirect()->route('categories.index');
}
我看
亲爱的所有人,我在MySQL中遇到了一个问题:我无法在MySQL命令行界面中执行DELETE FROM users where user_id ='1';。所以我在phpMyAdmin中尝试:使用图形用户界面删除一行,得到如下结果:
SQL查询:
DELETE FROM `health_portal`.`users` WHERE `users`.`user_id` =1
MySQL说:文档
Cannot delete or update a parent row: a foreign key constraint fails (`health_portal`.`users`,
标题说,这一切真的-我得到了一个FK约束失败时,试图重新索引类别产品。
完全例外是:
There was a problem with reindexing process.SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
(`krcscouk`.`catalog_category_product_index`, CONSTRAINT `FK_CAT_CTGR_PRD_IDX_PRD_ID_CAT_PRD_
当我执行下一个SQL代码时:
delete from product where idproduct = 2;
我得到了下一个错误:
Error Code: 1451. Cannot delete or update a parent row: a foreign key constraint fails (`store`.`sale_detail`, CONSTRAINT `fk_sale_detail_product1` FOREIGN KEY (`idproduct`) REFERENCES `product` (`idproduct`) ON DELETE NO ACTION ON U
照明\数据库\ QueryException (23000) SQLSTATE23000:完整性约束冲突: 1451无法删除或更新父行:外键约束失败(project-management.projects,constraint projects_company_id_foreign外键(company_id)引用companies (id)) (SQL: delete from companies where id = 2)
我无法从数据库对象中删除一行。在我的例子中,db对象具有自索引。
字段root_id与key_id (主键)具有外键关系。引用完整性设计为ON UPDATE NO ACTION AND ON DELETE NO ACTION。即使是我也无法删除。
CONSTRAINT `fk_MyTab` FOREIGN KEY (`root_id`) REFERENCES `MyTab` (`key_id`) ON DELETE NO ACTION ON UPDATE NO ACTION)
我必须从这个表WHERE key_id = root_id中删除记录。
当我尝试删除时,我得到了以下内容。
错误代码
我有4个sql表。
create table general(regno int NOT NULL primary key);
create table company_information(cregno int NOT NULL primary key);
create table company_jobs (jcode int NOT NULL primary key, cregno int , foreign key(cregno) references company_information(cregno));
create table applied(cregno int ,
每当我试图删除/删除实体“候选人”时,我都会收到这个错误:
An exception occurred while executing 'DELETE FROM candidate WHERE id = ?' with params {"1":3}: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`ima`.`result`, CONSTRAINT `result
我检查了所有依赖于这个错误的问题,但找不到答案
这是我的EER图-- --我在销售中插入了一行,例如,( SellerFId=1,GoodFId=1,CustomerFId=1),所以我希望能够从自己的表中删除卖方或好人或客户,这样在Sales中插入行仍然保留,我在Sales和其他表之间使用了这个外部约束
ON DELETE NO ACTION ON UPDATE NO ACTION
但是,当我从自己的表中删除卖方或好人或客户时,mysql不允许我并给我此错误
不能删除或更新父行:外键约束失败(newmobarakkabul.sales,constraint fk_Sellers_has
我有一个MySQL数据库。我想删除places.match_no > 26和matches.chart_id = 106中的所有匹配。
DELETE matches
FROM kk_matches AS matches
INNER JOIN places ON places.id = matches.place_id
AND places.match_no > 26
WHERE matches.chart_id = 106
这将导致一个错误:
#1451 - Cannot delete or update a parent row: a foreign key constrai
在我的项目中创建多个迁移之后,我想回滚来更新一些东西,但是当我尝试删除projects表时突然发现了这个错误。我检查了外键约束,但找不到错误。
[Illuminate\Database\QueryException]
SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or upda
te a parent row: a foreign key constraint fails (SQL: drop table `pr
mysql> delete from faculty where fid in ( select fid from class);
错误1451 (23000):无法删除或更新父行:外键约束失败(ass1.class、约束class_ibfk_1外键(fid)引用faculty (fid))
这是抛出上述错误。我该怎么办?
命令:
DELETE FROM `meetings`.`meetingparticipants` WHERE `meetingparticipants`.`idParticipants` =503 AND `meetingparticipants`.`idMeetings` =83
我知道我的数据库中有一个简单的错误。我正在尝试从会议参与者表中删除一行,但收到以下错误:
#1451 - Cannot delete or update a parent row: a foreign key constraint fails (`meetings`.`invoices`, CONSTRAIN
我正在使用此模型代码删除一条记录。
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['