首先在当前目录下建立数据库,代码以下:sql
[ouyangxi@DESKTOP-QNJ4U2U code]$ sqlite3 tax.db SQLite version 3.22.0 2018-01-22 18:45:57 Enter ".help" for usage hints. sqlite>
接着在数据库中建立表:数据库
sqlite> create table tax( ...> id integer PRIMARY KEY AUTOINCREMENT, //序号的自增 ...> startTime timestamp, //建立时间 ...> money varchar(20), ...> unite varchar(20) ...> );
在数据库中能够建立多个表:spa
sqlite> create table tax1( ...> id integer PRIMARY KEY AUTOINCREMENT, ...> startTime timestamp, ...> money varchar(20), ...> unite varchar(20) ...> );
使用以下代码显示表的个数:code
sqlite> .tables
tax tax1
同时也可删除多余的表:sqlite
sqlite> drop table tax1; sqlite> .tables tax
接下来进行初始化赋值:blog
sqlite> insert into tax(startTime,money,unite) values (current_timestamp,'20','元'); sqlite> insert into tax(startTime,money,unite) values (current_timestamp,'30','元'); sqlite> insert into tax(startTime,money,unite) values (current_timestamp,'40','元');
然后能够进行查询it
sqlite> select * from tax;//所有查询 sqlite> select * from tax where money='20';//条件查询 sqlite> select id, datetime(startTime),money,unite from tax;//日期查询
完成SQlite3数据库的创建io