You might want to use a full pathname to ensure that the file is in the directory that you think it is in. The "ex1.db" file is created if it does not previously exist. The example above causes the database file named "ex1.db" to be opened and used. Use ".open FILENAME" to reopen on a persistent database. To use a persistent disk file as the database, enter the ".open" command immediately after the terminal window starts up: SQLite version 3.36.0 18:36:39Ĭonnected to a transient in-memory database. However, because double-clicking starts the sqlite3.exe without command-line arguments, no database file will have been specified, so SQLite will use a temporary database that is deleted when the session exits. Windows users can double-click on the sqlite3.exe icon to cause the command-line shell to pop-up a terminal window running SQLite. This feature allows you to enter SQL commands that span multiple lines. If you omit the semicolon, sqlite3 will give you a continuation prompt and wait for you to enter more text to complete the SQL command. Make sure you type a semicolon at the end of each SQL command! The sqlite3 program looks for a semicolon to know when your SQL command is complete. Use the interrupt character (usually a Control-C) to stop a long-running SQL statement. Terminate the sqlite3 program by typing your system End-Of-File character (usually a Control-D). Sqlite> insert into tbl1 values('goodbye', 20) Sqlite> insert into tbl1 values('hello!',10) Sqlite> create table tbl1(one text, two int) Type in SQL statements (terminated by a semicolon), press "Enter" and the SQL will be executed.įor example, to create a new SQLite database named "ex1" with a single table named "tbl1", you might do this: $ sqlite3 ex1 On startup, the sqlite3 program will show a brief banner message then prompt you to enter SQL. If no database file is specified on the command-line, a temporary database is created and automatically deleted when the "sqlite3" program exits. If the named file does not exist, a new database file with the given name will be created automatically. Start the sqlite3 program by typing "sqlite3" at the command prompt, optionally followed by the name the file that holds the SQLite database (or ZIP archive). This document provides a brief introduction on how to use the sqlite3 program. The SQLite project provides a simple command-line program named sqlite3 (or sqlite3.exe on Windows) that allows the user to manually enter and execute SQL statements against an SQLite database or against a ZIP archive.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |