8

I execute: sqlite3 -init mydata.sql mydb with the following as the only line in mydata.sql:

DROP TABLE IF EXISTS [Album];

I get the following error:

Error: near line 1: near "DROP": syntax error

I've whittled the input file to virtually nothing and I always get this syntax error message no matter what command I enter and always on line 1. It looks like it thinks there's some unusual character but I can's see what it could be. Any thoughts?

2
  • 1
    How are you saving the file? What's the encoding? Commented Dec 6, 2011 at 20:00
  • @tripleee Good call. My SQL script was in UTF-8 and no unexpected unprintable characters were showing up (see harsh's answer) but I was still getting the error until I changed the encoding to UTF-8 without the byte order mark. Commented Jun 6, 2014 at 0:00

2 Answers 2

6

If you use Notepad++ or other similar text editor, enable showing all symbol.

In Notepad++, view->show symbol->Show All characters

Also check Encoding of this file (Menu->Encoding). You might want to forcefully change encoding to ANSI/UTF-8 (Menu->Encoding->Convert to ANSI).

Sign up to request clarification or add additional context in comments.

Comments

1

I had the same error with the Chinook database and SQLite version 3.19.3, so I opened the SQL file (Chinook_Sqlite_AutoIncrementPKs.sql) with Sublime Text and save it like UTF-8 (to eliminate the BOM indicator).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.