Stefan
Stefan

Reputation: 749

How to paste multiline SQL statements into the sqlite3 shell

I use a script to generate CREATE statements for tables and want to paste these statements into the SQLite command shell. Unfortunately it does not work as expected, because the line break seems to cause trouble.

When I copy the following example table

CREATE TABLE ExampleTable (
    columnA INTEGER, 
    columnB VARCHAR(2), 
    columnC INTEGER
);

into the SQLite command shell, I get this result:

sqlite>     CREATE TABLE ExampleTable (
   ...> 

and the shell waits for input until I press the semicolon (;). Is this linked to the separator? I tried setting it to ';' manually but there was no effect. I would expect the shell to accept the commands regardless of the format of its input string. The very same command works for instance in the Firefox Addon SQLite Manager, also I could read them from a file. For the quick test nevertheless, I would rather just paste the CREATE statements. I am sure that is a very easy thing to do, I just could not find the proper hint. Thanks!

Upvotes: 5

Views: 5677

Answers (2)

msikon
msikon

Reputation: 21

  1. Save CREATE statements to txt file
  2. Open database in SQLite command shell
  3. Use command .read file_name.txt

Upvotes: 2

bat_ventzi
bat_ventzi

Reputation: 346

This issue is discussed in this forum.

What I've found:

  • sqlite shell v.3.14.1 - has this issue;
  • sqlite shell v.3.8.2 - don't have this issue;
  • sqlite shell v.3.16.2 (the latest binary that you can download at the moment) - don't have this issue;

So you can just download the new version.

Upvotes: 0

Related Questions