Home > Announcements > Command line sqlite

Command line sqlite

Execute the command sqlite3 at the command prompt passing the file name of the database:

$ sqlite3 <database name>.sqlite3

You should see output similar to the following:

SQLite version 3.6.10
Enter “.help” for instructions
Enter SQL statements terminated with a “;”
sqlite>

Check that the version is correct.  People running sqlite3 in emacs may need to set sql-sqlite-program.

Enter ‘.help’ to see the list of commands that provide information or set options. Input starting with a ‘.’ (period) signals non-SQL and should be one of those commands.  All other input will be interpreted as SQL and should be terminated with a ‘;’ (semi-colon).

Enter ‘.quit’ to exit.  Some other commands you will likely find useful are ‘.headers’, ‘.tables’, and ‘.schema’.

When using rails with sqlite3, this same functionality can be started with ’script/dbconsole’.

Categories: Announcements Tags:
  1. Ron Newman
    October 10th, 2009 at 10:45 | #1

    "Check that the version is correct" -- I have SQLite 3.6.3, not 3.6.10 -- is that OK?

    I noticed that sqlite3 does not understand the SQL statement "describe ".

  2. Antony
    October 10th, 2009 at 11:40 | #2

    That version is fine. Anything greater than 3.4, as required by Assignment 0.

    I should have been more clear about the version. Depending on your system you may have both sqlite and sqlite3 commands. The former may be major version 2. You don't want to use that.

    Regarding DESCRIBE, that would depend on if you mean as defined by the SQL-92 standard or the command line sql processor keyword as implemented by some database vendors. DESCRIBE in SQL-92 is used to gain information about the input or output of prepared statements. DESCRIBE in SQL*Plus and some other command line sql processors provides information about a tables columns. In sqlite3 use the .schema command I mentioned before.

  3. Ron Newman
    October 10th, 2009 at 14:13 | #3

    I meant the MySQL DESCRIBE. Didn't realize it wasn't standardized. Thanks.

  4. Priyanka
    October 11th, 2009 at 20:07 | #4

    @Antony
    I am having this:
    C:\>sqlite3 ex1
    SQLite version 3.6.17
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    is it ok? just to check before to start the assignment.

  5. Antony
    October 11th, 2009 at 22:50 | #5

    As I clarified to Ron, any version greater than 3.4 and since the rest of the output matches my example above, you should be fine.

  6. Priyanka
    October 12th, 2009 at 21:05 | #6

    @Antony
    Thanks.! It worked.

  1. No trackbacks yet.