2.创建数据库:sqlite3 db
参数:db,数据库名,如果不存在会自动创建,执行后会进入sqlite2命令环境,并生成文件名为db的单个文件。sqlite以简单闻名,果真十分精简。
3.查看帮助:.help
sqlite> .help
.backup ?DB? FILE Backup DB (default "main") to FILE
.bail ON|OFF Stop after hitting an error. Default OFF
.databases List names and files of attached databases
.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
.exit Exit this program
.explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
.genfkey ?OPTIONS? Options are:
--no-drop: Do not drop old fkey triggers.
--ignore-errors: Ignore tables with fkey errors
--exec: Execute generated SQL immediately
See file tool/genfkey.README in the source
distribution for further information.
.header(s) ON|OFF Turn display of headers on or off
.help Show this message
.import FILE TABLE Import data from FILE into TABLE
.indices ?TABLE? Show names of all indices
If TABLE specified, only show indices for tables
matching LIKE pattern TABLE.
.load FILE ?ENTRY? Load an extension library
.mode MODE ?TABLE? Set output mode where MODE is one of:
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 string
tabs Tab-separated values
tcl TCL list elements
.nullvalue STRING Print STRING in place of NULL values
.output FILENAME Send output to FILENAME
.output stdout Send output to the screen
.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
.schema ?TABLE? Show the CREATE statements
If TABLE specified, only show tables matching
LIKE pattern TABLE.
.separator STRING Change separator used by output mode and .import
.show Show the current values for various settings
.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
.width NUM NUM ... Set column widths for "column" mode
.timer ON|OFF Turn the CPU timer measurement on or off
sqlite>
4.查看所有数据库:.tablebases
sqlite> .databases
seq name file
--- -------------------------------------------------------------------------
0 main D:\My Documents\涓嬭浇\sqlite-3_6_20\db
sqlite>
5.查看当前数据库所有表:.tables
sqlite> .tables
sqlite>
创建表:1.支持的数据类型:
NULL 值为NULL INTEGER 值为带符号的整型,根据类别用1,2,3,4,6,8字节存储 REAL 值为浮点型,8字节存储 TEXT 值为text字符串,使用数据库编码(UTF-8, UTF-16BE or UTF-16-LE)存储 BLOB 值为二进制数据,具体看实际输入
2.创建表:create table ()
sqlite> create table test(id integer,name text); sqlite> .tables test sqlite>
创建表后,文件大小便由0变成了2K
3.执行插入:insert into tbName values() sqlite> insert into test values(1,'测试数据'); sqlite> select from test ; Error: near "from": syntax error sqlite> select * from test ; 1|测试数据 sqlite> 可以看到数据成功插入,并可使用select进行查询,默认情况下字段之间以"|"分隔. 4.使用.mode修改显示样式,可选择csv,column,html,insert,line,list,tabs,tcl
|
阅读(1183) | 评论(0) | 转发(0) |