SQLite数据库操作实践
SQLite数据库操作实践 SQLite存储类型 null - 空值 integer - 有符号整数,自增列定义 id integer primary key autoincrement real - 浮点数,存储为8-byte IEEE浮点数 text - 文本字符串 使用数据库编码(UTF-8, UTF-16BE 或 UTF-16LE)进行存储 blob - 二进
SQLite数据库操作实践
SQLite存储类型
null - 空值
integer - 有符号整数,自增列定义 id integer primary key autoincrement
real - 浮点数,存储为8-byte IEEE浮点数
text - 文本字符串 使用数据库编码(UTF-8, UTF-16BE 或 UTF-16LE)进行存储
blob - 二进制数据,如图片、声音等等
也可以接受其它数据类型例如datetime,varchar,nvarchar,decimal,float,double,bigint 等等
Last login: Tue Jan 7 19:05:33 2014 from 192.168.10.1
[myth@host10 ~]$ su
Password:
[root@host10 myth]# pwd //显示当前工作目录
/home/myth
进入SQLite命令行创建数据库并且打开数据库
[root@host10 myth]# sqlite3 bookstore.db
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .databases
seq name file
--- --------------- ----------------------------------------------------------
0 main /home/myth/bookstore.db
sqlite>
sqlite> .quit //退出SQLite命令行环境
[root@host10 myth]#
打开数据库
[root@host10 myth]# sqlite3 bookstore.db //如果数据库已经存在了,则打开数据库
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
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
下一篇: (转)Java事务处理类型及差异总结
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论