我想從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小白所以感謝您的提示。
我想有些行已經插入,那麼你需要更新它不插入 –