SQLite,是一款轻型的数据库,是遵守ACID的关系型数据库管理系统,它包含在一个相对小的C库中。它是D.RichardHipp建立的公有领域项目。它的设计目标是嵌入式的,而且目前已经在很多嵌入式产品中使用了它,它占用资源非常的低,在嵌入式设备中,可能只需要几百K的内存就够了。它能够Windows/Linux/Unix等等主流的操作系统,同时能够跟很多程序语言相结合,比如 Tcl、C#、PHP、Java等,还有ODBC接口,同样比起Mysql、PostgreSQL这两款开源的世界著名数据库管理系统来讲,它的处理速度比他们都快。SQLite第一个Alpha版本诞生于2000年5月。 至2015年已经有15个年头,SQLite也迎来了一个版本 SQLite 3已经发布。

主流的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轻量级数据库的更多相关文章

  1. Linux 安装 MySQL 8 数据库(图文详细教程)

    本教程手把手教你如何在 Linux 安装 MySQL 数据库,以 CentOS 7为例. 1. 下载并安装 MySQL 官方的 Yum Repository wget -i -c https://re ...

  2. linux安装达梦数据库8

    PS.本次测试只是为了项目需要,但是在部署和启动程序的时候发生了一系列的报错,由此记录下来为日后作参考 安装达梦数据库 1. 达梦数据库(DM8)简介 达梦数据库管理系统是武汉达梦公司推出的具有完全自 ...

  3. Linux安装Sqlite

    下载SQLite源代码sqlite-3.6.23.1.tar.gz 复制sqlite-3.6.23.1.tar.gz到linux上的/usr/src目录 解压源代码 tar -xvzf sqlite- ...

  4. Linux安装卸载Mysql数据库

    关于mysql数据库在Linux下的应用一直以来都是我认为比较棘手的,这次通过搭建Linux学习环境顺便研究和学习Mysql数据库在Linux下安装和卸载. 1.先来看看卸载吧,如下图所示: 以上的命 ...

  5. Linux安装MariaDB+初始化数据库

    背景说明: 在数据库中,mysql的是常用的数据库之一:作为一款开源的软件被广大公司所使用. 但是,mysql在被Oracle公司收购后,难免在以后会有取消开源的问题.所以急需一款新的数据库产品替换m ...

  6. [ios]sqlite轻量级数据库学习连接

    SQLLite (一)基本介绍 http://blog.csdn.net/lyrebing/article/details/8224431 SQLLite (二) :sqlite3_open, sql ...

  7. Sqlite轻量级数据库

     SQLite,是一款轻量型的数据库,是遵守ACID(原子性.一致性.隔离性.持久性)的关联式数据库管理系统,多用于嵌入式开发中. SQLite的数据类型:Typelessness(无类型), 可以保 ...

  8. Android SQLite轻量级数据库的删除和查找操作

    今天主要是补充昨天的内容,本打算合成一章的,但是毕竟一天一天的内容写习惯了. 就这样继续昨天的,昨天只讲了创建以及增加和查询, 其实用法都差不多,今天学长也是在原有的基础上写的,还顺便融合了Share ...

  9. Android SQLite轻量级数据库(简单介绍)

    SQLite它是相当于嵌入到安卓里的一个小数据库吧, 它也可以使用SQL语句进行数据库的增删改查操作,但是是SQL1992的语句. 然后SQLite也有自己的语句,但是学过SQL的应该都会发现,它比较 ...

随机推荐

  1. 由于拷贝的文件太大,不可能一直开着SHELL,所以让SCP后台运行

    原文地址: http://blog.itpub.net/90618/viewspace-750822/ 1:开一个终端,scp命令运行后,输入密码让其拷贝 # scp chris@221.179.1. ...

  2. 在Windows下编译Emacs

    在Windows下编译Emacs Windows下编译好的Emacs主要有两个版本,一个来自http://nqmacs.sourceforge.net/,另一个来自http://www.crasseu ...

  3. UIScrollView视差模糊效果

    UIScrollView视差模糊效果 效果 源码 https://github.com/YouXianMing/Animations // // ScrollBlurImageViewControll ...

  4. 北京市基本医疗保险A类定点医疗机构名单(2010-09-29)

    1.中国医学科学院北京协和医院 2.首都医科大学附属北京同仁医院 3.首都医科大学宣武医院 4.首都医科大学附属北京友谊医院 5.北京大学第一医院 6.北京大学人民医院 7.北京大学第三医院 8.北京 ...

  5. 项目bug的修正

    这几个月来,大部分业余时间,都花在阅读软件工程和编译原理方面的书籍上了.软件工程方面的书,包括软件需求.风险管理.敏捷建模,系统设计,软件项目管理,还有一些类似于的沉思录书籍等. 在这些书中,都只是讲 ...

  6. UTF-8,Unicode,GBK,希腊字母读法,ASCII码表,HTTP错误码,URL编码表,HTML特殊字符,汉字编码简明对照表

    UNICODE,GBK,UTF-8区别 UNICODE,GBK,UTF-8区别    简单来说,unicode,gbk和大五码就是编码的值,而utf-8,uft-16之类就是这个值的表现形式.而前面那 ...

  7. SCSI contrller的几种类型的区别

    在VMware vSphere Web Client中, 可以为虚拟机添加一个新的SCSI controller, 选项中包含如下的类型, 那么他们有什么区别呢? 如何选择呢?   BusLogic ...

  8. C# 开发者代码审查清单

    这是为C#开发者准备的通用性代码审查清单,可以当做开发过程中的参考.这是为了确保在编码过程中,大部分通用编码指导原则都能注意到.对于新手和缺乏经验(0到3年工作经验)的开发者,参考这份清单编码会很帮助 ...

  9. SQL2005,错误 0xc00470fe 数据流任务 产品级别对于 组件“源 - 2009_txt”(1) 而言不足

    今天在将txt文件导入MSSQL2005时,出了这个错误,到网上查了一下资料,说是因为没有安装SQL 2005 SP1的原因,所以我就下载了个. 安装后,再次导入数据,OK 没问题了.http://w ...

  10. iframe之onload事件小记

    项目上做了一个具有wizard(向导)功能的菜单导航页面,子页面的引入通过主页面上iframe的src属性切换实现.为了有个良好的交互体验,每次更新iframe的src时,主页面上都显示一个模态的lo ...