我在一个文件中编写了数据库模式(到目前为止只有一个表)和该表的 INSERT 语句。然后我创建数据库如下:
$ sqlite3 newdatabase.db
SQLite version 3.4.0
Enter ".help" for instructions
sqlite> .read ./schema.sql
SQL error near line 16: near "s": syntax error
我的文件的第 16 行如下所示:
INSERT INTO table_name (field1, field2) VALUES (123, 'Hello there\'s');
问题是单引号的转义字符。我也尝试过双重转义单引号(使用\\\'
而不是\'
),但这也不起作用。我究竟做错了什么?