ubuntu下sqlite3的用法(以后会讲到wxWidgets使用sqlite3开发)

1.先在线安装sqlite3,试用一下命令安装
ubuntu@ubuntu-virtual-machine:~$ sudo apt-get install sqlite3
2.安装成功后测试会出现
ubuntu@ubuntu-virtual-machine:~$ sqlite3
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .exit
3.查找sqlite3的路径
ubuntu@ubuntu-virtual-machine:~$ which sqlite3
/usr/bin/sqlite3
ubuntu@ubuntu-virtual-machine:~$ ls
core              OSlab1    Public                           Videos
Desktop           OSlab2    Qt                               vmwaretools
Documents         OSlab3    sqlite-amalgamation-3080403      wx
Downloads         OSlab4    sqlite-amalgamation-3080403.zip  wx3.0
examples.desktop  OSlab5    StuMana                          wxlab
Music             Pictures  Templates
4.具体sqlite3操作的实例
ubuntu@ubuntu-virtual-machine:~$ mkdir mydb
ubuntu@ubuntu-virtual-machine:~$ cd mydb
ubuntu@ubuntu-virtual-machine:~/mydb$ ls
ubuntu@ubuntu-virtual-machine:~/mydb$ sqlite3 stu.db
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table stu(sno int primary key, sname text not null, sage int);
sqlite> insert into stu(1, ‘Lisi‘, 20);
Error: near "1": syntax error
sqlite> insert into stu values(1, ‘lisi‘, 20);
sqlite> insert into stu values(2, ‘zhangsan‘, 18);
sqlite> select * from stu;
1|lisi|20
2|zhangsan|18
sqlite> .exit
ubuntu@ubuntu-virtual-machine:~/mydb$ ls
stu.db
5.具体sqlite3操作的实例
ubuntu@ubuntu-virtual-machine:~$ cd StuMana
ubuntu@ubuntu-virtual-machine:~/StuMana$ sqlite3 stuinfo.db
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table stuinfo (id char(10),name char(15) not null,dormitoryid char(20) not null,phone char(11),qq char(13));
sqlite> insert into stuinfo values(‘1115115247‘,‘LiYa‘,‘15#501‘,‘15530061772‘,‘614100932‘);
sqlite> insert into stuinfo values(‘1115115276‘,‘ZhangAihua‘,‘15#424‘,‘18330000036‘,‘627100056‘);
sqlite> select * from stuinfo;
1115115247|LiYa|15#501|15500761772|614100932
1115115276|ZhangAihua|15#424|18330000036|627100056
sqlite> .exit
ubuntu@ubuntu-virtual-machine:~/StuMana$ ls
bin           stuinfo.db      StuMana.depend   WxWizFrame.fbp
GUIFrame.cpp  StuManaApp.cpp  StuMana.layout   WxWizFrame.fbp.bak
GUIFrame.h    StuManaApp.h    StuManaMain.cpp
obj           StuMana.cbp     StuManaMain.h
ubuntu@ubuntu-virtual-machine:~/StuMana$ 

ubuntu下sqlite3的用法(以后会讲到wxWidgets使用sqlite3开发),古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。