我想从WordPress的帖子移动内容使用于夹层:MySQL错误1452(23000):不能添加或更新子行,外键约束失败
INSERT INTO mezdb.blog_blogpost (id, user_id, publish_date,
content, title, description, slug, updated, status)
SELECT DISTINCT ID, post_author, post_date, post_content, post_title, post_excerpt,
post_name, post_modified, post_status
FROM wpdb.wp_posts WHERE wp_posts.post_type IN ('story');
,但我得到
ERROR 1452(23000):不能添加或更新子行:外键约束 失败(
mezdb
blog_blogpost
,约束site_id_refs_id_ac21095f
外键(site_id
)参考文献django_site
(id
))
mezdb模式:
CREATE TABLE `blog_blogpost` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`comments_count` integer NOT NULL,
`keywords_string` varchar(500) NOT NULL,
`rating_count` integer NOT NULL,
`rating_sum` integer NOT NULL,
`rating_average` double precision NOT NULL,
`site_id` integer NOT NULL,
`title` varchar(500) NOT NULL,
`slug` varchar(2000),
`_meta_title` varchar(500),
`description` longtext NOT NULL,
`gen_description` bool NOT NULL,
`created` datetime,
`updated` datetime,
`status` integer NOT NULL,
`publish_date` datetime,
`expiry_date` datetime,
`short_url` varchar(200),
`in_sitemap` bool NOT NULL,
`content` longtext NOT NULL,
`user_id` integer NOT NULL,
`allow_comments` bool NOT NULL,
`featured_image` varchar(255)
);
我在SQL小白所以感谢您的提示。
我想有些行已经插入,那么你需要更新它不插入 –