<bdo id='CPb70'></bdo><ul id='CPb70'></ul>
      <tfoot id='CPb70'></tfoot>
    1. <legend id='CPb70'><style id='CPb70'><dir id='CPb70'><q id='CPb70'></q></dir></style></legend>

      1. <i id='CPb70'><tr id='CPb70'><dt id='CPb70'><q id='CPb70'><span id='CPb70'><b id='CPb70'><form id='CPb70'><ins id='CPb70'></ins><ul id='CPb70'></ul><sub id='CPb70'></sub></form><legend id='CPb70'></legend><bdo id='CPb70'><pre id='CPb70'><center id='CPb70'></center></pre></bdo></b><th id='CPb70'></th></span></q></dt></tr></i><div id='CPb70'><tfoot id='CPb70'></tfoot><dl id='CPb70'><fieldset id='CPb70'></fieldset></dl></div>

        <small id='CPb70'></small><noframes id='CPb70'>

      2. 违反完整性约束:1452 无法添加或更新子行:

        时间:2023-06-03
      3. <i id='Aooct'><tr id='Aooct'><dt id='Aooct'><q id='Aooct'><span id='Aooct'><b id='Aooct'><form id='Aooct'><ins id='Aooct'></ins><ul id='Aooct'></ul><sub id='Aooct'></sub></form><legend id='Aooct'></legend><bdo id='Aooct'><pre id='Aooct'><center id='Aooct'></center></pre></bdo></b><th id='Aooct'></th></span></q></dt></tr></i><div id='Aooct'><tfoot id='Aooct'></tfoot><dl id='Aooct'><fieldset id='Aooct'></fieldset></dl></div>

            <tbody id='Aooct'></tbody>
                  <bdo id='Aooct'></bdo><ul id='Aooct'></ul>
                  <legend id='Aooct'><style id='Aooct'><dir id='Aooct'><q id='Aooct'></q></dir></style></legend>

                  <small id='Aooct'></small><noframes id='Aooct'>

                • <tfoot id='Aooct'></tfoot>
                • 本文介绍了违反完整性约束:1452 无法添加或更新子行:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将值插入到我的评论表中,但出现错误.它说我无法添加或更新子行,我不知道这是什么意思.

                  我的架构看起来像这样

                  -- ------------------------------ `comments` 的表结构-- --------------------------如果存在评论",则删除表;创建表`评论`(`id` varchar(36) 非空,`project_id` varchar(36) 非空,`user_id` varchar(36) 非空,`task_id` varchar(36) 非空,`data_type_id` varchar(36) 非空,`data_path` varchar(255) 默认为空,`消息`长文本,`created` 日期时间默认为 NULL,`修改的`日期时间默认为空,主键(`id`),KEY`fk_comments_users`(`user_id`),KEY`fk_comments_projects1`(`project_id`),KEY`fk_comments_data_types1`(`data_type_id`),约束`fk_comments_data_types1` FOREIGN KEY (`data_type_id`) REFERENCES `data_types` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,约束`fk_comments_projects1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,约束`fk_comments_users`外键(`user_id`)引用`users`(`id`)在删除时没有操作更新没有操作) 引擎=InnoDB 默认字符集=utf32;-- ---------------------------- 评论记录-- ---------------------------- ----------------------------`projects`的表结构-- --------------------------如果存在项目",则删除表;创建表`项目`(`id` varchar(36) 非空,`user_id` varchar(36) 非空,`title` varchar(45) 默认为空,`描述`长文本,`created` 日期时间默认为 NULL,`修改的`日期时间默认为空,主键(`id`),密钥`fk_projects_users1`(`user_id`),约束`fk_projects_users1`外键(`user_id`)引用`users`(`id`)在删除时无操作更新无操作) 引擎=InnoDB 默认字符集=utf32;-- ---------------------------- 项目记录-- --------------------------INSERT INTO `projects` VALUES ('50dcbc72-3410-4596-8b71-0e80ae7aaee3', '50dcbc5c-d684-40bf-9715-0becae7aaee3', 'Brand New Project', 'This is a122012'-27 15:24:02', '2012-12-27 15:24:02');

                  我试图做的 mysql 语句看起来像这样

                  INSERT INTO `anthonyl_fbpj`.`comments`(`project_id`、`user_id`、`task_id`、`data_type_id`、`message`、`modified`、`created`、`id`)值 ('50dc845a-83e4-4db3-8705-5432ae7aaee3', '50dcbc5c-d684-40bf-9715-0becae7aaee3', '1', '50d32e5c-abdc-48e1a-abdc-48e1a-abdc-48e12012-12-27 19:20:46'、'2012-12-27 19:20:46'、'50dcf3ee-8bf4-4685-aa45-4eb4ae7aaee3')

                  我得到的错误看起来像这样

                  <块引用>

                  SQLSTATE[23000]:违反完整性约束:1452 无法添加或更新子行:外键约束失败(anthonyl_fbpj.comments, CONSTRAINT fk_comments_projects1外键 (project_id) 参考 projects (id) ON DELETE NO更新操作无操作)

                  解决方案

                  这只是意味着您正在插入的表 comments 上列 project_id 的值没有存在于表 projects 上.请记住,表 comments 上列 project_id 的值取决于表 Projects 上的 ID 值.

                  您为列 project_id 插入的值 50dc845a-83e4-4db3-8705-5432ae7aaee3 在表 projects 中不存在.>

                  I am trying to insert values into my comments table and I am getting a error. Its saying that I can not add or update child row and I have no idea what that means.

                  my schema looks something like this

                  -- ----------------------------
                  -- Table structure for `comments`
                  -- ----------------------------
                  DROP TABLE IF EXISTS `comments`;
                  CREATE TABLE `comments` (
                    `id` varchar(36) NOT NULL,
                    `project_id` varchar(36) NOT NULL,
                    `user_id` varchar(36) NOT NULL,
                    `task_id` varchar(36) NOT NULL,
                    `data_type_id` varchar(36) NOT NULL,
                    `data_path` varchar(255) DEFAULT NULL,
                    `message` longtext,
                    `created` datetime DEFAULT NULL,
                    `modified` datetime DEFAULT NULL,
                    PRIMARY KEY (`id`),
                    KEY `fk_comments_users` (`user_id`),
                    KEY `fk_comments_projects1` (`project_id`),
                    KEY `fk_comments_data_types1` (`data_type_id`),
                    CONSTRAINT `fk_comments_data_types1` FOREIGN KEY (`data_type_id`) REFERENCES `data_types` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
                    CONSTRAINT `fk_comments_projects1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
                    CONSTRAINT `fk_comments_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
                  ) ENGINE=InnoDB DEFAULT CHARSET=utf32;
                  
                  -- ----------------------------
                  -- Records of comments
                  -- ----------------------------
                  
                  -- ----------------------------
                  -- Table structure for `projects`
                  -- ----------------------------
                  DROP TABLE IF EXISTS `projects`;
                  CREATE TABLE `projects` (
                    `id` varchar(36) NOT NULL,
                    `user_id` varchar(36) NOT NULL,
                    `title` varchar(45) DEFAULT NULL,
                    `description` longtext,
                    `created` datetime DEFAULT NULL,
                    `modified` datetime DEFAULT NULL,
                    PRIMARY KEY (`id`),
                    KEY `fk_projects_users1` (`user_id`),
                    CONSTRAINT `fk_projects_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
                  ) ENGINE=InnoDB DEFAULT CHARSET=utf32;
                  
                  -- ----------------------------
                  -- Records of projects
                  -- ----------------------------
                  INSERT INTO `projects` VALUES ('50dcbc72-3410-4596-8b71-0e80ae7aaee3', '50dcbc5c-d684-40bf-9715-0becae7aaee3', 'Brand New Project', 'This is a brand new project', '2012-12-27 15:24:02', '2012-12-27 15:24:02');
                  

                  and the mysql statement I am trying to do looks something like this

                  INSERT INTO `anthonyl_fbpj`.`comments` (`project_id`, `user_id`, `task_id`, `data_type_id`, `message`, `modified`, `created`, `id`) 
                  VALUES ('50dc845a-83e4-4db3-8705-5432ae7aaee3', '50dcbc5c-d684-40bf-9715-0becae7aaee3', '1', '50d32e5c-abdc-491a-a0ef-25d84e9f49a8', 'this is a test', '2012-12-27 19:20:46', '2012-12-27 19:20:46', '50dcf3ee-8bf4-4685-aa45-4eb4ae7aaee3')
                  

                  the error I get looks like this

                  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (anthonyl_fbpj.comments, CONSTRAINT fk_comments_projects1 FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE NO ACTION ON UPDATE NO ACTION)

                  解决方案

                  It just simply means that the value for column project_id on table comments you are inserting doesn't exist on table projects. Bear in mind that the values of column project_id on table comments is dependent on the values of ID on table Projects.

                  The value 50dc845a-83e4-4db3-8705-5432ae7aaee3 you are inserting for column project_id does not exist on table projects.

                  这篇关于违反完整性约束:1452 无法添加或更新子行:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:mySQL 返回每个类别的前 5 个 下一篇:SQL DELETE 与 JOIN 另一个表的 WHERE 条件

                  相关文章

                  <legend id='isW4U'><style id='isW4U'><dir id='isW4U'><q id='isW4U'></q></dir></style></legend>

                  <small id='isW4U'></small><noframes id='isW4U'>

                  • <bdo id='isW4U'></bdo><ul id='isW4U'></ul>

                  <tfoot id='isW4U'></tfoot>

                    1. <i id='isW4U'><tr id='isW4U'><dt id='isW4U'><q id='isW4U'><span id='isW4U'><b id='isW4U'><form id='isW4U'><ins id='isW4U'></ins><ul id='isW4U'></ul><sub id='isW4U'></sub></form><legend id='isW4U'></legend><bdo id='isW4U'><pre id='isW4U'><center id='isW4U'></center></pre></bdo></b><th id='isW4U'></th></span></q></dt></tr></i><div id='isW4U'><tfoot id='isW4U'></tfoot><dl id='isW4U'><fieldset id='isW4U'></fieldset></dl></div>