Sqlite is kinda frustrating. Each time I run a command, I'm not able to use the up down left right arrows to retrieve my previously typed commands. Is there any way to enable this?
Another question: I have the following table
CREATE TABLE resource (
resourceID INTEGER PRIMARY KEY AUTOINCREMENT,
resourceType STRING,
userID INTEGER DEFAULT -1
);
and I insert as follows:
insert into resource values(null, "razor");
but its not allowing me to do so because I have only inserted into 2 columns and not specified anything for the userID column. But I thought the point of DEFAULT was to default the values to -1 if nothing was inserted. Am I missing something here?
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). If the named file does not exist, a new database file with the given name will be created automatically.
Type in SQL statements (terminated by a semicolon), press "Enter" and the SQL will be executed. You can terminate the sqlite3 program by typing your systems End-Of-File character (usually a Control-D). Use the interrupt character (usually a Control-C) to stop a long-running SQL statement.
There are three commands in data manipulation language group: INSERT: This command is used to create a record. UPDATE: It is used to modify the records. DELETE: It is used to delete records.
By default sqlite database is created in the application's packagename. You can not view this location if you are executing your code in real device. If you want to view your sqlite database then save the database to sd card using below syntax. File dbfile = new File("/sdcard/mydb/mydatabase.
A quick solution is to launch SQLite with ReadLine support like following:
rlwrap sqlite3 database.db
If rlwrap
is not installed, you can do so on Ubuntu using the command:
sudo apt-get install rlwrap
For other Linux versions, check here.
rlwrap
is a ReadLine wrapper, a small utility that uses the GNU readline library to allow the editing of keyboard input for any other command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With