SQLite源码安装部署
1.下载
下载地址:
https://www.sqlite.org/download.html
我这里下载的是:
sqlite-autoconf-3390400.tar.gz
2.解压编译
[root@localhost soft]#yum install gcc
[root@localhost soft]# tar -zxvf sqlite-autoconf-3390400.tar.gz
[root@localhost soft]# cd sqlite-autoconf-3390400
# ./configure --prefix=/usr/local/sqlite3
[root@localhost sqlite-autoconf-3390400]#make
[root@localhost sqlite-autoconf-3390400]#make install
3.添加环境变量
export LD_LIBRARY_PATH=/usr/local/sqlite3/lib
export PATH=/usr/local/sqlite3/bin:$PATH
4.验证
[root@localhost sqlite-autoconf-3390400]# sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
创建表
[root@localhost /]# sqlite3 a.db
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
CREATE TABLE COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY REAL
);
查看表
sqlite> .table
COMPANY
写入数据:
sqlite> INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
...> VALUES (1, 'Paul', 32, 'California', 20000.00 );
sqlite> INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
...> VALUES (2, 'Allen', 25, 'Texas', 15000.00 );
sqlite> INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
...> VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );
sqlite>
sqlite> INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
...> VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );
sqlite>
sqlite> INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
...> VALUES (5, 'David', 27, 'Texas', 85000.00 );
sqlite>
sqlite> INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
...> VALUES (6, 'Kim', 22, 'South-Hall', 45000.00 );
查看
sqlite> select * from COMPANY;
1|Paul|32|California|20000.0
2|Allen|25|Texas|15000.0
3|Teddy|23|Norway|20000.0
4|Mark|25|Rich-Mond |65000.0
5|David|27|Texas|85000.0
6|Kim|22|South-Hall|45000.0
5.进入到数据文件查看
[root@localhost orchestrator]# sqlite3 a.db
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .table
sqlite> .exit