将 .sql 文件导入 SQLite [英] Importing .sql file into 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 中都是自动递增的); - 删除
ENGINE
和DEFAULT CHARSET
; - 删除
LOCK
/UNLOCK
命令; - 使
INSERT
命令的记录更少; - 用
''
替换\'
引用.
- delete
COMMENT
s on the table fields; - remove
AUTO_INCREMENT
fromid
(INTEGER PRIMARY KEY
fields are autoincrementing in SQLite anyway); - remove
ENGINE
andDEFAULT CHARSET
; - remove
LOCK
/UNLOCK
commands; - make the
INSERT
commands have fewer records; - replace
\'
quoting with''
.
这篇关于将 .sql 文件导入 SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!