缘由:之前旧网站有些数据要复制过来,通过网页复制粘贴则过慢,可通过如下方式进行较快:
1、通过数据库工具将原来数据导出为sql文件,然后通过数据库工具在新网站服务器中新建类似名字,如typecho_contents_bak,再将刚才导出的sql文件导入到这些带_bak的相应数据表中。
2、因为新网站已经有了一些数据,所以需要插入数据到表中。采用方法类似:
INSERT INTO Websites (name, country)
SELECT app_name,
country
FROM apps;
3、实际操作时,据此演化出来的代码如(是将新数据导入旧数据库中,这样需要导入的较少):
INSERT INTO `typecho_contents` (`title`,`created`,`modified`,`text`,`order`,`authorId`,`template`,`type`,`status`,`password`,`commentsNum`,`allowComment`,`allowPing`,`allowFeed`,`parent`,`views`)
SELECT `title`,`created`,`modified`,`text`,`order`,`authorId`,`template`,`type`,`status`,`password`,`commentsNum`,`allowComment`,`allowPing`,`allowFeed`,`parent`,`views` FROM `typecho_contents_new` WHERE cid>1