Linux安装SQLite轻量级数据库
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Linux安装SQLite轻量级数据库,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5275字,纯文字阅读大概需要8分钟。
内容图文
![Linux安装SQLite轻量级数据库](/upload/InfoBanner/zyjiaocheng/476/8814e415cc1c43d5b7116a776e3fda87.jpg)
主流的sqlite3,占用内存小,处理时速度快,跨平台
01、下载
https://www.sqlite.org/download.html
02、安装
bin文件安装
解压下载的文件,放到 /usr/bin/
rpm文件安装
yum install -y sqlite sqlite-devel
03、运行
sqlite3
04、测试基本命令
sqlite3 test.db #创建数据库
create table mytable(id integer primary key, value text);
insert into mytable(id, value) values(1, ‘Micheal‘);
select * from mytable;
###设置格式化查询结果
sqlite> .mode column;
sqlite> .header on;
sqlite> select * from test;
id value
----------- -------------
1 Micheal
2 Jenny
3 Francis
4 Kerk
.mode column 将设置为列显示模式,.header 将显示列名
修改表结构,增加列:
sqlite> alter table mytable add column email text not null ‘‘ collate nocase;;
创建视图:
sqlite> create view nameview as select * from mytable;
创建索引:
sqlite> create index test_idx on mytable(value);
显示表结构:
sqlite> .schema [table]
获取所有表和视图:
sqlite > .tables
获取指定表的索引列表:
sqlite > .indices [table ]
导出数据库到 SQL 文件:
sqlite > .output [filename ]
sqlite > .dump
sqlite > .output stdout
从 SQL 文件导入数据库:
sqlite > .read [filename ]
格式化输出数据到 CSV 格式:
sqlite >.output [filename.csv ]
sqlite >.separator ,
sqlite > select * from test;
sqlite >.output stdout
从 CSV 文件导入数据到表中:
sqlite >create table newtable ( id integer primary key, value text );
sqlite >.import [filename.csv ] newtable
备份数据库:
/* usage: sqlite3 [database] .dump > [filename] */
sqlite3 mytable.db .dump > backup.sql
恢复数据库:
/* usage: sqlite3 [database ] < [filename ] */
sqlite3 mytable.db < backup.sql
sqlite3的帮助信息
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 <table> 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
遇到问题,解决问题,思考问题。
Linux安装SQLite轻量级数据库
标签:and load header 占用 abs 解决问题 lock 导出数据 open
本文系统来源:http://www.cnblogs.com/xiaochina/p/6444736.html
内容总结
以上是互联网集市为您收集整理的Linux安装SQLite轻量级数据库全部内容,希望文章能够帮你解决Linux安装SQLite轻量级数据库所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。