将 .sql 文件导入 SQLite [英] Importing .sql file into SQLite

查看:62
本文介绍了将 .sql 文件导入 SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将大型 .sql 文件导入 SQLite .db 文件,但出现以下错误:

I'm trying to import a large .sql file into an SQLite .db file, but I'm getting the following errors:

sqlite> .read ./smsCorpus_en_2012.04.30.sql 
Error: near line 23: near "COMMENT": syntax error
Error: near line 50: near "LOCK": syntax error
Error: near line 52: near "some1": syntax error
Error: near line 58: near "s": syntax error
Error: near line 60: near "s": syntax error
Error: near line 66: near "UNLOCK": syntax error

该文件位于 http:///wing.comp.nus.edu.sg:8080/SMSCorpus/data/corpus/smsCorpus_en_sql_2012.04.30.zip(直接文件链接)链接在此页面http://wing.comp.nus.edu.sg:8080/SMSCorpus/history.jsp

The file is located at http://wing.comp.nus.edu.sg:8080/SMSCorpus/data/corpus/smsCorpus_en_sql_2012.04.30.zip (direct file link) linked on this page http://wing.comp.nus.edu.sg:8080/SMSCorpus/history.jsp

只是一个警告,文件很大...不确定这是不是问题?

just a warning, the file is quite large...not sure if this is the issue?

推荐答案

该文件是 MySQL 转储文件.为了让 SQLite 理解它,你必须:

That file is a MySQL dump. To make SQLite understand it, you have to:

  • 删除表字段上的COMMENT
  • id 中删除 AUTO_INCREMENT(无论如何,INTEGER PRIMARY KEY 字段在 SQLite 中都是自动递增的);
  • 删除ENGINEDEFAULT CHARSET
  • 删除LOCK/UNLOCK命令;
  • 使 INSERT 命令的记录更少;
  • '' 替换 \' 引用.
  • delete COMMENTs on the table fields;
  • remove AUTO_INCREMENT from id (INTEGER PRIMARY KEY fields are autoincrementing in SQLite anyway);
  • remove ENGINE and DEFAULT CHARSET;
  • remove LOCK/UNLOCK commands;
  • make the INSERT commands have fewer records;
  • replace \' quoting with ''.

这篇关于将 .sql 文件导入 SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆