.backup ?DB? FILE Backup DB (default "main") to FILE .bail on|off Stop after hitting an error. Default OFF .binary on|off Turn binary output on or off. Default OFF .clone NEWDB Clone data into NEWDB from the existing database .databases List names and files of attached databases .dbinfo ?DB? Show status information about the database .dump ?TABLE? ... Dump the database in an SQL text format If TABLE specified, only dump tables matching LIKE pattern TABLE. .echo on|off Turn command echo on or off .eqp on|off Enable or disable automatic EXPLAIN QUERY PLAN .exit Exit this program .explain ?on|off? Turn output mode suitable for EXPLAIN on or off. With no args, it turns EXPLAIN on. .fullschema Show schema and the content of sqlite_stat tables .headers on|off Turn display of headers on or off .help Show this message .import FILE TABLE Import data from FILE into TABLE .indexes ?TABLE? Show names of all indexes If TABLE specified, only show indexes for tables matching LIKE pattern TABLE. .limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT .log FILE|off Turn logging on or off. FILE can be stderr/stdout .mode MODE ?TABLE? Set output mode where MODE is one of: ascii Columns/rows delimited by 0x1F and 0x1E csv Comma-separated values column Left-aligned columns. (See .width) html HTML
code insert SQL insert statements for TABLE line One value per line list Values delimited by .separator strings tabs Tab-separated values tcl TCL list elements .nullvalue STRING Use STRING in place of NULL values .once FILENAME Output for the next SQL command only to FILENAME .open ?FILENAME? Close existing database and reopen FILENAME .output ?FILENAME? Send output to FILENAME or stdout .print STRING... Print literal STRING .prompt MAIN CONTINUE Replace the standard prompts .quit Exit this program .read FILENAME Execute SQL in FILENAME .restore ?DB? FILE Restore content of DB (default "main") from FILE .save FILE Write in-memory database into FILE .scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off .schema ?TABLE? Show the CREATE statements If TABLE specified, only show tables matching LIKE pattern TABLE. .separator COL ?ROW? Change the column separator and optionally the row separator for both the output mode and .import .shell CMD ARGS... Run CMD ARGS... in a system shell .show Show the current values for various settings .stats on|off Turn stats on or off .system CMD ARGS... Run CMD ARGS... in a system shell .tables ?TABLE? List names of tables If TABLE specified, only list tables matching LIKE pattern TABLE. .timeout MS Try opening locked tables for MS milliseconds .timer on|off Turn SQL timer on or off .trace FILE|off Output each SQL statement as it is run .vfsname ?AUX? Print the name of the VFS stack .width NUM1 NUM2 ... Set column widths for "column" mode Negative values right-justify
sqlite> .schema system CREATE TABLE system (_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT UNIQUE ON CONFLICT REPLACE,value TEXT); CREATE INDEX systemIndex1 ON system (name);
sqlite> .mode insert sqlite> select * from system; INSERT INTO table VALUES(1,'volume_music','15'); INSERT INTO table VALUES(2,'volume_ring','5'); INSERT INTO table VALUES(3,'volume_system','7'); INSERT INTO table VALUES(4,'volume_voice','4'); INSERT INTO table VALUES(5,'volume_alarm','6'); INSERT INTO table VALUES(6,'volume_notification','5'); INSERT INTO table VALUES(7,'volume_bluetooth_sco','7');
如我要在system表里面插入一条数据:
insert into system values('45','sqlite','jscese');
这里插入数据要跟创建的时候数量要对应,不然会报:
Error: table table_name has * columns but * values were supplied
3.查询指定数据:
sqlite> select * from system where name='sqlite'; INSERT INTO table VALUES(45,'sqlite','jscese');
根据表类型值来筛选查询,这里表的属性有
_id ,name,value ,可在创建命令中看到!
4.删除数据:
delete from system where value='jscese';
删除整个表:
drop table table_name
5.更新表数据:
45|sqlite|jscese sqlite> update system set name='sqlite3' where value='jscese'; sqlite> select * from system where value='jscese'; 45|sqlite3|jscese